/
nc_first_fail_spec.rb
45 lines (38 loc) 路 1.36 KB
/
nc_first_fail_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'nc_first_fail'
describe NcFirstFail do
let(:formatter) { NcFirstFail.new(StringIO.new) }
let(:current_dir) { File.basename(File.expand_path '.') }
let(:failure_count) { 1 }
let(:summary_notification) do
instance_double(RSpec::Core::Notifications::SummaryNotification,
formatted_duration: '0.0001 seconds',
totals_line: '3 examples, 1 failure, 1 pending',
failure_count: failure_count,
)
end
let(:failed_example_notification) do
instance_double(RSpec::Core::Notifications::FailedExampleNotification,
example: double(:example,
metadata: {full_description: '_full_description_'},
exception: '_exception_',
),
)
end
it 'sends a failure notification for the first failure only' do
expect(TerminalNotifier).to receive(:notify).with(
"_full_description_\n_exception_",
title: "#{Nc::FAILURE_EMOJI} #{current_dir}: Failure",
)
formatter.example_failed failed_example_notification
expect(TerminalNotifier).to_not receive(:notify)
formatter.example_failed failed_example_notification
expect(TerminalNotifier).to_not receive(:notify)
formatter.dump_summary summary_notification
end
context 'with all examples passing' do
let(:failure_count) { 0 }
it 'sends a success summary notification' do
formatter.dump_summary summary_notification
end
end
end