Skip to content

Commit

Permalink
Match files both named test_*.rb and *_test.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed Sep 19, 2024
1 parent bec6bb2 commit 585a603
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lua/neotest-minitest/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ NeotestAdapter.root = lib.files.match_root_pattern("Gemfile", ".gitignore")
---@param file_path string
---@return boolean
function NeotestAdapter.is_test_file(file_path)
return vim.endswith(file_path, "_test.rb")
return vim.endswith(file_path, "_test.rb") or string.match(file_path, "/test_.+%.rb$") ~= nil
end

---Filter directories when searching for test files
Expand Down
6 changes: 5 additions & 1 deletion tests/adapter/plugin_spec.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
local plugin = require("neotest-minitest")

describe("is_test_file", function()
it("matches test files", function()
it("matches Rails-style test file", function()
assert.equals(true, plugin.is_test_file("./test/foo_test.rb"))
end)

it("matches minitest-style test file", function()
assert.equals(true, plugin.is_test_file("./test/test_foo.rb"))
end)

it("does not match plain ruby files", function()
assert.equals(false, plugin.is_test_file("./lib/foo.rb"))
end)
Expand Down

0 comments on commit 585a603

Please sign in to comment.