Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lua/neotest-rspec/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ M.formatter = function()
return "NeotestFormatter"
end

M.formatter_path = function()
-- Get the directory of the current init.lua file
local plugin_root =
vim.fn.fnamemodify(vim.api.nvim_get_runtime_file("lua/neotest-rspec/init.lua", false)[1], ":h:h:h")

-- Construct the path to formatter.rb
local formatter_path = plugin_root .. "/neotest_formatter.rb"

-- Return the absolute path
return vim.fn.resolve(formatter_path)
end

return M
21 changes: 8 additions & 13 deletions lua/neotest-rspec/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,6 @@ function NeotestAdapter.discover_positions(path)
})
end

local function get_formatter_path()
-- Get the directory of the current init.lua file
local plugin_root =
vim.fn.fnamemodify(vim.api.nvim_get_runtime_file("lua/neotest-rspec/init.lua", false)[1], ":h:h:h")

-- Construct the path to formatter.rb
local formatter_path = plugin_root .. "/neotest_formatter.rb"

-- Return the absolute path
return vim.fn.resolve(formatter_path)
end

---@param args neotest.RunArgs
---@return neotest.RunSpec | nil
function NeotestAdapter.build_spec(args)
Expand All @@ -110,8 +98,8 @@ function NeotestAdapter.build_spec(args)
if match and match ~= 0 then engine_name = string.sub(path, 0, match - 1) end
local results_path = config.results_path()

local formatter_path = get_formatter_path()
local formatter = config.formatter()
local formatter_path = config.formatter_path()

local script_args = {
"-f",
Expand Down Expand Up @@ -264,6 +252,13 @@ setmetatable(NeotestAdapter, {
return opts.formatter
end
end
if is_callable(opts.formatter_path) then
config.formatter_path = opts.formatter_path
elseif opts.formatter_path then
config.formatter_path = function()
return opts.formatter_path
end
end
return NeotestAdapter
end,
})
Expand Down