Skip to content

Commit f032e3c

Browse files
authored
Give anonymous examples unique names (#40)
Otherwise, they won't be displayed in VS Code's Test Explorer correctly.
1 parent 97e72d3 commit f032e3c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/ruby_lsp/ruby_lsp_rspec/code_lens.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def initialize(response_builder, uri, dispatcher)
2121
@path = T.let(T.must(uri.to_standardized_path), String)
2222
@group_id = T.let(1, Integer)
2323
@group_id_stack = T.let([], T::Array[Integer])
24+
@anonymous_example_count = T.let(0, Integer)
2425
dispatcher.register(self, :on_call_node_enter, :on_call_node_leave)
2526

2627
@base_command = T.let(
@@ -93,7 +94,8 @@ def generate_name(node)
9394
argument.slice
9495
end
9596
else
96-
"<unnamed>"
97+
@anonymous_example_count += 1
98+
"<unnamed-#{@anonymous_example_count}>"
9799
end
98100
end
99101

spec/ruby_lsp_rspec_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,9 @@ def test_baz; end
380380

381381
expect(response.count).to eq(15)
382382

383-
expect(response[3].command.arguments[1]).to eq("<unnamed>")
383+
expect(response[3].command.arguments[1]).to eq("<unnamed-1>")
384384
expect(response[6].command.arguments[1]).to eq("<var1>")
385-
expect(response[9].command.arguments[1]).to eq("<unnamed>")
385+
expect(response[9].command.arguments[1]).to eq("<unnamed-2>")
386386
expect(response[12].command.arguments[1]).to eq("<var2>")
387387
end
388388
end

0 commit comments

Comments
 (0)