Skip to content

Commit a39dd2a

Browse files
committed
Document reason for normalizing test names
1 parent 9d04fcb commit a39dd2a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/ruby_lsp/ruby_lsp_rails/rails_test_style.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ def on_call_node_enter(node)
9090

9191
test_name = first_arg.content
9292
test_name = "<empty test name>" if test_name.empty?
93+
94+
# Rails' `test "foo bar"` helper defines a method `def test_foo_bar`. We normalize test names
95+
# the same way (spaces to underscores, prefix with `test_`) to match the actual method names
96+
# Rails uses at runtime, ensuring proper test discovery and execution.
9397
rails_normalized_name = "test_#{test_name.gsub(/\s+/, "_")}"
9498

9599
add_test_item(node, rails_normalized_name)

0 commit comments

Comments
 (0)