diff --git a/lib/ci/reporter/rspec.rb b/lib/ci/reporter/rspec.rb index 0ca2820..e45a67a 100644 --- a/lib/ci/reporter/rspec.rb +++ b/lib/ci/reporter/rspec.rb @@ -81,6 +81,10 @@ def example_started(name) def example_failed(name, counter, failure) @formatter.example_failed(name, counter, failure) + # In case we fail in before(:all) + if @suite.testcases.empty? + example_started(name) + end spec = @suite.testcases.last spec.finish spec.failures << RSpecFailure.new(failure) diff --git a/spec/ci/reporter/rspec_spec.rb b/spec/ci/reporter/rspec_spec.rb index dc31cd3..6e3c9e4 100644 --- a/spec/ci/reporter/rspec_spec.rb +++ b/spec/ci/reporter/rspec_spec.rb @@ -105,4 +105,21 @@ @fmt.example_passed(example) @fmt.dump_summary(0.1, 1, 0, 0) end + + it "should create a test suite with failure in before(:all)" do + example_group = mock "example group" + example_group.stub!(:description).and_return "A context" + + @formatter.should_receive(:start) + @formatter.should_receive(:example_group_started).with(example_group) + @formatter.should_receive(:example_started).once + @formatter.should_receive(:example_failed).once + @formatter.should_receive(:dump_summary) + @report_mgr.should_receive(:write_report) + + @fmt.start(2) + @fmt.example_group_started(example_group) + @fmt.example_failed("should fail", 1, @error) + @fmt.dump_summary(0.1, 1, 0, 0) + end end