File tree Expand file tree Collapse file tree 5 files changed +49
-5
lines changed Expand file tree Collapse file tree 5 files changed +49
-5
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,9 @@ def notify(summary)
18
18
priority : priority )
19
19
end
20
20
21
- def notify_failure
21
+ def notify_failure ( failure_message = 'Failed' )
22
22
return unless options [ :notification ]
23
- Guard ::Compat ::UI . notify ( "Failed" ,
23
+ Guard ::Compat ::UI . notify ( failure_message ,
24
24
title : @options [ :title ] ,
25
25
image : :failed ,
26
26
priority : 2 )
Original file line number Diff line number Diff line change @@ -22,6 +22,13 @@ def all_green?
22
22
exit_code . zero?
23
23
end
24
24
25
+ # Returns true if there is an error AND examples are not run.
26
+ def error_and_examples_not_run?
27
+ error = "error occurred outside of examples"
28
+ summary_regexp = %r{0 examples, 0 failures( \( (\d +) #{ error } \) )?}
29
+ results . summary . match? ( summary_regexp )
30
+ end
31
+
25
32
private
26
33
27
34
def _run
Original file line number Diff line number Diff line change @@ -64,12 +64,18 @@ def _really_run(cmd, options)
64
64
65
65
process = RSpecProcess . new ( cmd , file , options )
66
66
results = process . results
67
-
68
67
inspector . failed ( results . failed_paths )
69
- notifier . notify ( results . summary )
70
- _open_launchy
71
68
72
69
all_green = process . all_green?
70
+
71
+ # Notify user of error and that examples are not run.
72
+ if process . error_and_examples_not_run?
73
+ notifier . notify_failure ( 'Error/s occurred and examples are not run.' )
74
+ else
75
+ notifier . notify ( results . summary )
76
+ end
77
+
78
+ _open_launchy
73
79
return yield all_green if block_given?
74
80
all_green
75
81
end
Original file line number Diff line number Diff line change 64
64
context "with the failure code for normal test failures" do
65
65
let ( :exit_code ) { Guard ::RSpec ::Command ::FAILURE_EXIT_CODE }
66
66
67
+ before do
68
+ summary = '2 examples, 1 failure'
69
+ allow ( results ) . to receive ( :summary ) . and_return ( summary )
70
+ end
71
+
67
72
it "fails" do
68
73
expect { subject } . to_not raise_error
69
74
end
70
75
71
76
it { is_expected . to_not be_all_green }
77
+
78
+ it { is_expected . to_not be_error_and_examples_not_run }
72
79
end
73
80
74
81
context "with no failures" do
148
155
subject
149
156
end
150
157
end
158
+
159
+ context "with error outside examples" do
160
+ let ( :exit_code ) { 2 }
161
+
162
+ before do
163
+ summary = '0 examples, 0 failures, 1 error occurred outside of examples'
164
+ allow ( results ) . to receive ( :summary ) . and_return ( summary )
165
+ end
166
+
167
+ it { is_expected . to_not be_all_green }
168
+
169
+ it { is_expected . to be_error_and_examples_not_run }
170
+ end
151
171
end
152
172
end
Original file line number Diff line number Diff line change 25
25
allow ( results ) . to receive ( :summary ) . and_return ( "Summary" )
26
26
allow ( results ) . to receive ( :failed_paths ) . and_return ( [ ] )
27
27
28
+ allow ( process ) . to receive ( :error_and_examples_not_run? ) . and_return ( false )
28
29
allow ( Guard ::RSpec ::RSpecProcess ) . to receive ( :new ) . and_return ( process )
29
30
allow ( process ) . to receive ( :all_green? ) . and_return ( true )
30
31
allow ( process ) . to receive ( :results ) . and_return ( results )
339
340
runner . run ( paths )
340
341
end
341
342
343
+ it "notifies that examples are not run" do
344
+ allow ( process ) . to receive ( :all_green? ) . and_return ( false )
345
+ allow ( process ) . to receive ( :error_and_examples_not_run? ) . and_return ( true )
346
+
347
+ expect ( notifier ) . to receive ( :notify_failure )
348
+ . with ( /Error\/ s occurred and examples are not run./ )
349
+
350
+ runner . run ( paths )
351
+ end
352
+
342
353
describe "return value" do
343
354
subject { runner . run ( paths ) }
344
355
You can’t perform that action at this time.
0 commit comments