olimorris / neotest-rspec

🧪 Neotest adapter for RSpec. Works in Docker containers too
MIT License
88 stars 25 forks source link

[Bug]: `specify` blocks are not recognized #57

Closed Slotos closed 12 months ago

Slotos commented 12 months ago

RSpec test

RSpec.describe "something" do
  specify { expect { raise }.not_to raise_error }
end

Error messages

No response

Describe the bug

What I expect to happen

The test examples declared with specify to be reported in summary, sign column, and on failure.

What actually happens

The test examples declared with specify are largely ignored.

Reproduce the bug

Open the example spec file and:

Minimal fix diff

diff --git a/lua/neotest-rspec/init.lua b/lua/neotest-rspec/init.lua
index d12e686..f3c816e 100644
--- a/lua/neotest-rspec/init.lua
+++ b/lua/neotest-rspec/init.lua
@@ -61,12 +61,12 @@ function NeotestAdapter.discover_positions(path)
     )) @namespace.definition

     ((call
-      method: (identifier) @func_name (#eq? @func_name "it")
+      method: (identifier) @func_name (#match? @func_name "^(it|specify)$")
       block: (block (_) @test.name)
     )) @test.definition

     ((call
-      method: (identifier) @func_name (#eq? @func_name "it")
+      method: (identifier) @func_name (#match? @func_name "^(it|specify)$")
       block: (do_block (_) @test.name)
       !arguments
     )) @test.definition

I'd create a PR, but while I have a fix for my specific case, I'm not familiar with the test framework to quickly cover it with tests. I might still provide one later, but I can't make any promises.

Final checks

olimorris commented 12 months ago

Fantastic thank you. And your explanation was as good as a PR.

I haven't figured out how to get the tests working in a GitHub Action but the changes worked locally.

Closed as per 51a3b866d85733d2df2c6b5a16d75ce6ed2fbade