1; Adapted from the following sources:
2; Minitest: https://github.com/zidhuss/neotest-minitest/blob/main/lua/neotest-minitest/init.lua
3; RSpec: https://github.com/olimorris/neotest-rspec/blob/main/lua/neotest-rspec/init.lua
4
5; Minitest
6;; Rails unit tests
7(class
8 name: [
9 (constant) @run
10 (scope_resolution scope: (constant) name: (constant) @run)
11 ]
12 (superclass (scope_resolution) @superclass (#match? @superclass "(::IntegrationTest|::TestCase|::SystemTestCase)$"))
13) @minitest-test
14
15(call
16 method: (identifier) @run (#eq? @run "test")
17 arguments: (argument_list (string (string_content) @name))
18) @minitest-test
19
20; Methods that begin with test_
21(method
22 name: (identifier) @run (#match? @run "^test_")
23) @minitest-test
24
25; System tests that inherit from ApplicationSystemTestCase
26(class
27 name: (constant) @run (superclass) @superclass (#match? @superclass "(ApplicationSystemTestCase)$")
28) @minitest-test
29
30; RSpec
31
32; Example groups with literals
33(call
34 method: (identifier) @run (#any-of? @run "describe" "context")
35 arguments: (argument_list . (_) @name)
36) @rspec-test
37
38; Examples
39(call
40 method: (identifier) @run (#any-of? @run "it" "its" "specify")
41 arguments: (argument_list (string (string_content) @name))
42) @rspec-test
43
44; Examples (one-liner syntax)
45(call
46 method: (identifier) @run (#any-of? @run "it" "its" "specify")
47 block: (_) @name
48 !arguments
49) @rspec-test