Skip to content

Commit 7c84df6

Browse files
authored
Add @RUBY_TEST_NAME capture for test nodes (#97)
Reordered and added `@RUBY_TEST_NAME` capture to test method arguments and blocks to provide explicit test name references for: - test method with string argument - describe/context/it/its/specify methods with arguments - it/its/specify methods with blocks without arguments This capture can be references in Zed tasks via `ZED_CUSTOM_RUBY_TEST_NAME` variable. For example, to run a single Minitest properly we need to define the following Zed task: ```json { "label": "test $ZED_RELATIVE_FILE -n /$ZED_CUSTOM_RUBY_TEST_NAME/", "command": "bin/rails", "args": [ "test", "$ZED_RELATIVE_FILE", "-n", "/$ZED_CUSTOM_RUBY_TEST_NAME/" ], "tags": ["ruby-test"] } ```
1 parent 2bd9e29 commit 7c84df6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

languages/ruby/runnables.scm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
(
1818
(call
1919
method: (identifier) @run (#eq? @run "test")
20-
arguments: (argument_list (string (string_content) @name))
2120
) @_ruby-test
21+
arguments: (argument_list (string (string_content) @name @RUBY_TEST_NAME))
2222
(#set! tag ruby-test)
2323
)
2424

@@ -42,16 +42,16 @@
4242
(
4343
(call
4444
method: (identifier) @run (#any-of? @run "describe" "context" "it" "its" "specify")
45-
arguments: (argument_list . (_) @name)
4645
) @_ruby-test
46+
arguments: (argument_list . (_) @name @RUBY_TEST_NAME)
4747
(#set! tag ruby-test)
4848
)
4949

5050
; Examples (one-liner syntax)
5151
(
5252
(call
5353
method: (identifier) @run (#any-of? @run "it" "its" "specify")
54-
block: (_) @name
54+
block: (_) @name @RUBY_TEST_NAME
5555
!arguments
5656
) @_ruby-test
5757
(#set! tag ruby-test)

0 commit comments

Comments
 (0)