File tree Expand file tree Collapse file tree 4 files changed +29
-5
lines changed Expand file tree Collapse file tree 4 files changed +29
-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,15 @@ 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
+ example_count , failure_count , pending_count =
28
+ _parse_summary ( results . summary )
29
+
30
+ !all_green? && \
31
+ example_count == 0 && failure_count == 0 && pending_count == 0
32
+ end
33
+
25
34
private
26
35
27
36
def _run
@@ -85,6 +94,14 @@ def _warn_unless_absolute_path(formatter_tmp_file)
85
94
Compat ::UI . warning ( format ( msg , formatter_tmp_file . inspect ) )
86
95
end
87
96
97
+ def _parse_summary ( summary )
98
+ summary_regexp = /(\d +) examples, (\d +) failures( \( (\d +) pending\) )?/
99
+ summary . match ( summary_regexp ) do |m |
100
+ return m [ 1 ] . to_i , m [ 2 ] . to_i , m [ 4 ] . to_i
101
+ end
102
+ [ 0 , 0 , 0 ]
103
+ end
104
+
88
105
attr_reader :command
89
106
attr_reader :exit_code
90
107
attr_reader :formatter_tmp_file
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 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 )
You can’t perform that action at this time.
0 commit comments