ZIm/extensions/ruby/languages/ruby/runnables.scm
Vitaly Slobodin 5af116d676
ruby: Replace default tasks with a stub message (#16752)
The Ruby world has many testing frameworks:

- Minitest
- RSpec
- quickdraw
- tldr
- and many others.

Attempting to support all of them through a single `tasks.json` file is
a challenging task and nearly impossible. All testing frameworks have
different running options and commands. It's still possible to use
tree-sitter queries to detect runnables in Ruby code but Zed lacks the
ability to detect the testing framework in a project that can be used to
detect the correct commands to run tests or runnables. The end user
knows the correct command and it's wise to delegate creating the command
to them. It would be a bit strange to leave the user without any
guidance, so this commit adds example tasks for various Ruby testing
frameworks.

Closes #12579

Here is the screenshot how it looks:

![CleanShot 2024-07-01 at 19 37
08@2x](https://github.com/zed-industries/zed/assets/1894248/e9659822-6c02-4afb-a0e4-e9966b9fb2f5)


Release Notes:

- N/A
2024-08-29 10:32:05 -07:00

58 lines
1.5 KiB
Scheme

; Adapted from the following sources:
; Minitest: https://github.com/zidhuss/neotest-minitest/blob/main/lua/neotest-minitest/init.lua
; RSpec: https://github.com/olimorris/neotest-rspec/blob/main/lua/neotest-rspec/init.lua
; Tests that inherit from a specific class
(
(class
name: [
(constant) @run
(scope_resolution scope: (constant) name: (constant) @run)
]
(superclass (scope_resolution) @superclass (#match? @superclass "(::IntegrationTest|::TestCase|::SystemTestCase|Minitest::Test|TLDR)$"))
) @_ruby-test
(#set! tag ruby-test)
)
(
(call
method: (identifier) @run (#eq? @run "test")
arguments: (argument_list (string (string_content) @_name))
) @_ruby-test
(#set! tag ruby-test)
)
; Methods that begin with test_
(
(method
name: (identifier) @run (#match? @run "^test_")
) @_ruby-test
(#set! tag ruby-test)
)
; System tests that inherit from ApplicationSystemTestCase
(
(class
name: (constant) @run (superclass) @superclass (#match? @superclass "(ApplicationSystemTestCase)$")
) @_ruby-test
(#set! tag ruby-test)
)
; Examples
(
(call
method: (identifier) @run (#any-of? @run "describe" "context" "it" "its" "specify")
arguments: (argument_list . (_) @_name)
) @_ruby-test
(#set! tag ruby-test)
)
; Examples (one-liner syntax)
(
(call
method: (identifier) @run (#any-of? @run "it" "its" "specify")
block: (_) @_name
!arguments
) @_ruby-test
(#set! tag ruby-test)
)