diff --git a/lua/neotest-minitest/init.lua b/lua/neotest-minitest/init.lua index 3643469..cbeeefd 100644 --- a/lua/neotest-minitest/init.lua +++ b/lua/neotest-minitest/init.lua @@ -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 diff --git a/tests/adapter/plugin_spec.lua b/tests/adapter/plugin_spec.lua index 31c47d2..afc9075 100644 --- a/tests/adapter/plugin_spec.lua +++ b/tests/adapter/plugin_spec.lua @@ -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)