Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 6156004

Browse files
abickyJonRowe
authored andcommitted
Add errors_outside_of_examples_count to json output (#2448)
We run rspec in several workers and summarize their results using JSON output, so it is useful if the JSON includes errors_outside_of_examples_count information.
1 parent 8303659 commit 6156004

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/rspec/core/formatters/json_formatter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def dump_summary(summary)
2626
:duration => summary.duration,
2727
:example_count => summary.example_count,
2828
:failure_count => summary.failure_count,
29-
:pending_count => summary.pending_count
29+
:pending_count => summary.pending_count,
30+
:errors_outside_of_examples_count => summary.errors_outside_of_examples_count
3031
}
3132
@output_hash[:summary_line] = summary.totals_line
3233
end

spec/rspec/core/formatters/json_formatter_spec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
:example_count => 3,
8686
:failure_count => 1,
8787
:pending_count => 1,
88+
:errors_outside_of_examples_count => 0,
8889
},
8990
:summary_line => "3 examples, 1 failure, 1 pending"
9091
}
@@ -139,13 +140,13 @@
139140

140141
describe "#dump_summary" do
141142
it "adds summary info to the output hash" do
142-
send_notification :dump_summary, summary_notification(1.0, examples(10), examples(3), examples(4), 0)
143+
send_notification :dump_summary, summary_notification(1.0, examples(10), examples(3), examples(4), 0, 1)
143144
expect(formatter.output_hash[:summary]).to include(
144145
:duration => 1.0, :example_count => 10, :failure_count => 3,
145-
:pending_count => 4
146+
:pending_count => 4, :errors_outside_of_examples_count => 1
146147
)
147148
summary_line = formatter.output_hash[:summary_line]
148-
expect(summary_line).to eq "10 examples, 3 failures, 4 pending"
149+
expect(summary_line).to eq "10 examples, 3 failures, 4 pending, 1 error occurred outside of examples"
149150
end
150151
end
151152

0 commit comments

Comments
 (0)