Skip to content

Commit 64ba03d

Browse files
Fix announce_filters semantics for silence_filter_announcements=true
1 parent 3b74fd6 commit 64ba03d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/rspec/core/world.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,23 +106,21 @@ def reporter
106106
# Notify reporter of filters.
107107
def announce_filters
108108
fail_if_config_and_cli_options_invalid
109-
return if @configuration.silence_filter_announcements?
110-
111109
filter_announcements = []
112110

113111
announce_inclusion_filter filter_announcements
114112
announce_exclusion_filter filter_announcements
115113

116114
unless filter_manager.empty?
117115
if filter_announcements.length == 1
118-
reporter.message("Run options: #{filter_announcements[0]}")
116+
report_filter_message("Run options: #{filter_announcements[0]}")
119117
else
120-
reporter.message("Run options:\n #{filter_announcements.join("\n ")}")
118+
report_filter_message("Run options:\n #{filter_announcements.join("\n ")}")
121119
end
122120
end
123121

124122
if @configuration.run_all_when_everything_filtered? && example_count.zero? && !@configuration.only_failures?
125-
reporter.message("#{everything_filtered_message}; ignoring #{inclusion_filter.description}")
123+
report_filter_message("#{everything_filtered_message}; ignoring #{inclusion_filter.description}")
126124
filtered_examples.clear
127125
inclusion_filter.clear
128126
end
@@ -131,12 +129,17 @@ def announce_filters
131129

132130
example_groups.clear
133131
if filter_manager.empty?
134-
reporter.message("No examples found.")
132+
report_filter_message("No examples found.")
135133
elsif exclusion_filter.empty? || inclusion_filter.empty?
136-
reporter.message(everything_filtered_message)
134+
report_filter_message(everything_filtered_message)
137135
end
138136
end
139137

138+
# @private
139+
def report_filter_message(message)
140+
reporter.message(message) unless @configuration.silence_filter_announcements?
141+
end
142+
140143
# @private
141144
def everything_filtered_message
142145
"\nAll examples were filtered out"

0 commit comments

Comments
 (0)