Permalink
Browse files

Report exclusion filters (closes #347)

  • Loading branch information...
Pat Maddox
Pat Maddox committed Apr 16, 2011
1 parent eae6b43 commit 36237841db72eeb7797f199ad0fa057e36e26b40
Showing with 19 additions and 6 deletions.
  1. +4 −0 features/command_line/tag.feature
  2. +1 −2 lib/rspec/core/command_line.rb
  3. +14 −4 lib/rspec/core/world.rb
@@ -82,3 +82,7 @@ Feature: --tag option
"""
Then the examples should all pass
+ Scenario: filter examples with a simple tag, exclude examples with another tag
+ When I run `rspec . --tag focus --tag ~skip`
+ Then the output should contain "Run filtered using {:focus=>true}, excluding {:skip=>true}"
+ And the examples should all pass
@@ -16,8 +16,7 @@ def run(err, out)
@configuration.output_stream ||= out
@options.configure(@configuration)
@configuration.load_spec_files
- @world.announce_inclusion_filter
- @world.announce_exclusion_filter
+ @world.announce_filters
@configuration.reporter.report(@world.example_count) do |reporter|
begin
View
@@ -59,25 +59,35 @@ def preceding_declaration_line(filter_line)
end
end
- def announce_inclusion_filter
+ def announce_filters
+ filter_announcements = []
+ announce_inclusion_filter filter_announcements
+ announce_exclusion_filter filter_announcements
+
+ unless filter_announcements.empty?
+ @configuration.reporter.message("Run filtered #{filter_announcements.join(', ')}")
+ end
+ end
+
+ def announce_inclusion_filter(announcements)
if inclusion_filter
if @configuration.run_all_when_everything_filtered? && RSpec.world.example_count.zero?
@configuration.reporter.message "No examples were matched by #{inclusion_filter.inspect}, running all"
@configuration.clear_inclusion_filter
filtered_examples.clear
else
- @configuration.reporter.message "Run filtered using #{inclusion_filter.inspect}"
+ announcements << "using #{inclusion_filter.inspect}"
end
end
end
- def announce_exclusion_filter
+ def announce_exclusion_filter(announcements)
if exclusion_filter && RSpec.world.example_count.zero?
@configuration.reporter.message(
"No examples were matched. Perhaps #{exclusion_filter.inspect} is excluding everything?")
example_groups.clear
else
- @configuration.reporter.message "Run filtered excluding #{exclusion_filter.inspect}"
+ announcements << "excluding #{exclusion_filter.inspect}"
end
end

0 comments on commit 3623784

Please sign in to comment.