Skip to content

Commit f32f92c

Browse files
authored
Add code lens support for rails active support test cases using minitest/spec (#258)
* Add support for minitest spec * add a test
1 parent 3df6a98 commit f32f92c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/ruby_lsp/ruby_lsp_rails/code_lens.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def initialize(response_builder, uri, dispatcher)
5757
sig { params(node: Prism::CallNode).void }
5858
def on_call_node_enter(node)
5959
message_value = node.message
60-
return unless message_value == "test"
60+
return unless message_value == "test" || message_value == "it"
6161

6262
arguments = node.arguments&.arguments
6363
return unless arguments&.any?

test/ruby_lsp_rails/code_lens_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ class Test < ActiveSupport::TestCase
3232
assert_match("Debug", response[5].command.title)
3333
end
3434

35+
test "recognizes Rails Active Support test cases using minitest/spec" do
36+
response = generate_code_lens_for_source(<<~RUBY)
37+
class Test < ActiveSupport::TestCase
38+
it "an example" do
39+
# test body
40+
end
41+
end
42+
RUBY
43+
44+
# The first 3 responses are for the test class.
45+
# The last 3 are for the test declaration.
46+
assert_equal(6, response.size)
47+
assert_match("Run", response[3].command.title)
48+
assert_equal("bin/rails test /fake.rb:2", response[3].command.arguments[2])
49+
assert_match("Run In Terminal", response[4].command.title)
50+
assert_match("Debug", response[5].command.title)
51+
end
52+
3553
test "recognizes multiline escaped strings" do
3654
response = generate_code_lens_for_source(<<~RUBY)
3755
class Test < ActiveSupport::TestCase

0 commit comments

Comments
 (0)