Skip to content

Commit d710654

Browse files
authored
fix: fixed pending spec formatter (#89)
* Fix pending spec In case of a `pending` spec, the third argument is not provided. * Test fixed pending spec
1 parent ae6463d commit d710654

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/ruby_lsp/ruby_lsp_rspec/rspec_formatter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def generate_id(example)
8080
def adjust_backtrace(backtrace)
8181
# Correct the backtrace entry so that vscode recognized it as a link to open
8282
parts = backtrace.split(":", 3)
83-
parts[0].sub(/^\./, "file://" + File.expand_path(".")) + ":" + parts[1] + " : " + parts[2]
83+
parts[0].sub(/^\./, "file://" + File.expand_path(".")) + ":" + parts[1] + " : " + (parts[2] || "")
8484
end
8585
end
8686
end

spec/fixtures/rspec_example_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,9 @@
3030
it "raises an error" do
3131
raise "oops"
3232
end
33+
it "is pending but fixed" do
34+
pending
35+
expect { raise "error" }.to raise_error
36+
end
3337
end
3438
end

spec/rspec_formatter_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,22 @@
132132
"uri" => "file://#{fixture_path}",
133133
},
134134
},
135+
{
136+
"method" => "start",
137+
"params" => {
138+
"id" => "./spec/fixtures/rspec_example_spec.rb:11::./spec/fixtures/rspec_example_spec.rb:12::./spec/fixtures/rspec_example_spec.rb:33",
139+
"line" => "33",
140+
"uri" => "file://#{fixture_path}",
141+
},
142+
},
143+
{
144+
"method" => "fail",
145+
"params" => {
146+
"id" => "./spec/fixtures/rspec_example_spec.rb:11::./spec/fixtures/rspec_example_spec.rb:12::./spec/fixtures/rspec_example_spec.rb:33",
147+
"message" => "Expected pending 'No reason given' to fail. No error was raised.\n\n# file://#{fixture_path}:33 : ",
148+
"uri" => "file://#{fixture_path}",
149+
},
150+
},
135151
{ "method" => "finish", "params" => {} },
136152
]
137153

0 commit comments

Comments
 (0)