Skip to content

Commit

Permalink
reinstate filter messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed May 6, 2010
1 parent 9aaaf0f commit 3a37eed
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 30 deletions.
7 changes: 2 additions & 5 deletions cucumber.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion features/filtering/inclusion_filters.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"

5 changes: 5 additions & 0 deletions lib/rspec/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
8 changes: 3 additions & 5 deletions lib/rspec/core/example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 10 additions & 19 deletions lib/rspec/core/world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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={})
Expand Down

0 comments on commit 3a37eed

Please sign in to comment.