Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It notifies as soon as the first failure happens. If nothing fails, it notifies in the end.
- Loading branch information
1 parent
7a49b17
commit eab0e4d
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'nc' | ||
|
||
class NcFirstFail < Nc | ||
def example_failed(example) | ||
if @failed_examples.size == 0 | ||
say "\u26D4 #{example.metadata[:full_description]}", example.exception | ||
end | ||
super | ||
end | ||
|
||
def dump_summary(duration, example_count, failure_count, pending_count) | ||
super if failure_count == 0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'nc_first_fail' | ||
|
||
describe NcFirstFail do | ||
let(:formatter) { NcFirstFail.new(StringIO.new) } | ||
let(:example) { double 'example' } | ||
let(:example2) { double 'example2' } | ||
|
||
let(:failure) { "\u26D4" } | ||
let(:exception) { 'exception' } | ||
let(:description) { 'description' } | ||
|
||
before do | ||
example.should_receive(:metadata).any_number_of_times.and_return({:full_description => description}) | ||
example.should_receive(:exception).any_number_of_times.and_return(exception) | ||
end | ||
|
||
it 'notifies the first failure only' do | ||
TerminalNotifier.should_receive(:notify).with(exception, | ||
:title => "#{failure} #{description}" | ||
) | ||
|
||
formatter.example_failed(example) | ||
formatter.example_failed(example2) | ||
end | ||
|
||
it "doesn't notify in the end if there has been any failures" do | ||
TerminalNotifier.should_not_receive(:notify) | ||
|
||
formatter.dump_summary(0.0001, 2, 1, 0) | ||
end | ||
end |