Permalink
Browse files

reinstate filter messages

  • Loading branch information...
dchelimsky committed May 6, 2010
1 parent 9aaaf0f commit 3a37eed1500d4f0c724d5de1db96e000c81a4cbf
View
@@ -1,5 +1,2 @@
-<%
-std_opts = "--require features --strict --format progress --tags ~@wip features"
-%>
-default: <%= std_opts %>
-wip: --require features --tags @wip:3 --wip features
+default: --require features --strict --format progress --tags ~@wip features
+wip: --require features --tags @wip:3 --wip features
@@ -67,7 +67,8 @@ Feature: inclusion feature
end
"""
When I run "rspec spec/sample_spec.rb --format doc"
- Then I should see "group 1 example 1"
+ Then I should see "No examples were matched by {:focus=>true}, running all"
+ And I should see "group 1 example 1"
And I should see "group 1 example 2"
And I should see "group 2 example 1"
@@ -40,6 +40,11 @@ def default_options
/lib\/rspec\/(core|expectations|matchers|mocks)/]
}
end
+
+ def clear_filters
+ filter = nil
+ exclusion_filter = nil
+ end
def cleaned_from_backtrace?(line)
@options[:backtrace_clean_patterns].any? { |regex| line =~ regex }
@@ -189,11 +189,9 @@ def self.run(reporter)
reporter.add_example_group(self)
begin
eval_before_alls(example_group_instance)
- examples_result = run_examples(example_group_instance, reporter)
- child_results = children.map do |child|
- child.run(reporter)
- end
- examples_result && (children.empty? ? true : child_results)
+ result_for_this_group = run_examples(example_group_instance, reporter)
+ results_for_descendents = children.map {|child| child.run(reporter)}
+ result_for_this_group && (children.empty? ? true : results_for_descendents)
ensure
eval_after_alls(example_group_instance)
end
View
@@ -21,28 +21,19 @@ def shared_example_groups
end
def example_groups_to_run
- all_example_groups
- # @example_groups_to_run ||= begin
- # if inclusion_filter || exclusion_filter
- # if Rspec.configuration.run_all_when_everything_filtered? && filtered_example_groups.empty?
- # Rspec.configuration.puts "No examples were matched by #{inclusion_filter.inspect}, running all"
- # all_example_groups
- # else
- # Rspec.configuration.puts "Run filtered using #{inclusion_filter.inspect}"
- # filtered_example_groups
- # end
- # else
- # all_example_groups
- # end
- # end
- end
-
- def all_example_groups
- @example_groups.each { |g| g.examples_to_run.replace(g.examples) }
+ if inclusion_filter || exclusion_filter
+ if Rspec.configuration.run_all_when_everything_filtered? && total_examples_to_run == 0
+ Rspec.configuration.puts "No examples were matched by #{inclusion_filter.inspect}, running all"
+ Rspec.configuration.clear_filters
+ else
+ Rspec.configuration.puts "Run filtered using #{inclusion_filter.inspect}"
+ end
+ end
+ example_groups
end
def total_examples_to_run
- @total_examples_to_run ||= all_example_groups.collect {|g| g.descendents}.flatten.inject(0) { |sum, g| sum += g.examples_to_run.size }
+ @total_examples_to_run ||= example_groups.collect {|g| g.descendents}.flatten.inject(0) { |sum, g| sum += g.examples_to_run.size }
end
def apply_inclusion_filters(examples, conditions={})

0 comments on commit 3a37eed

Please sign in to comment.