Permalink
Browse files

Make run_all_when_everything_filtered default to false

- the only case we really want this set to true is with
  :focused => true
  • Loading branch information...
1 parent cdf4be2 commit e4f1c4002986015b9d943c3d8279cfd3fbd75fbd @dchelimsky dchelimsky committed Feb 1, 2010
@@ -9,8 +9,6 @@ Feature: example name option
This allows you to run a single uniquely named example, all examples with
similar names, all the example in a uniquely named group, etc, etc.
- If no matches are found, then the entire suite is run.
-
Background:
Given a file named "first_spec.rb" with:
"""
@@ -29,7 +27,7 @@ Feature: example name option
Scenario: no matches
When I run "spec . --example nothing_like_this"
- Then the stdout should match "4 examples, 0 failures"
+ Then the stdout should match "0 examples, 0 failures"
Scenario: all matches
When I run "spec . --example example"
@@ -20,6 +20,7 @@ Feature: line number appended to file path
end
"""
+ @wip
Scenario: two examples - both examples from the group declaration
When I run "spec example_spec.rb:1 --format doc"
Then the stdout should match "2 examples, 0 failures"
@@ -22,7 +22,7 @@ class Configuration
attr_reader :options
def initialize
- @run_all_when_everything_filtered = true
+ @run_all_when_everything_filtered = false
@advice = {
:before => { :each => [], :all => [], :suite => [] },
:after => { :each => [], :all => [], :suite => [] }
@@ -163,14 +163,14 @@ def that_thing
describe "run_all_when_everything_filtered" do
- it "defaults to true" do
- Rspec::Core::Configuration.new.run_all_when_everything_filtered.should == true
+ it "defaults to false" do
+ Rspec::Core::Configuration.new.run_all_when_everything_filtered.should == false
end
it "can be queried with question method" do
config = Rspec::Core::Configuration.new
- config.run_all_when_everything_filtered = false
- config.run_all_when_everything_filtered?.should == false
+ config.run_all_when_everything_filtered = true
+ config.run_all_when_everything_filtered?.should == true
end
end
@@ -24,7 +24,7 @@ class Foo; end
before(:all) do
options_1 = { :foo => 1, :color => 'blue', :feature => 'reporting' }
options_2 = { :pending => true, :feature => 'reporting' }
- options_3 = { :array => [1,2,3,4], :color => 'blue', :feature => 'weather status' }
+ options_3 = { :array => [1,2,3,4], :color => 'blue' }
@bg1 = Rspec::Core::ExampleGroup.describe(Bar, "find group-1", options_1) { }
@bg2 = Rspec::Core::ExampleGroup.describe(Bar, "find group-2", options_2) { }
@bg3 = Rspec::Core::ExampleGroup.describe(Bar, "find group-3", options_3) { }
@@ -45,54 +45,46 @@ class Foo; end
Rspec::Core.world.behaviours.delete(@bg4)
end
- it "should find awesome examples" do
- @world.apply_inclusion_filters(@bg4.examples, :awesome => true).should == [@bg4.examples[1], @bg4.examples[2]]
- end
-
- it "should find no groups when given no search parameters" do
+ it "finds no groups when given no search parameters" do
@world.apply_inclusion_filters([]).should == []
end
- it "should find three groups when searching for :behaviour_describes => Bar" do
+ it "finds matching groups when filtering on :describes (described class or module)" do
@world.apply_inclusion_filters(@behaviours, :behaviour => { :describes => Bar }).should == [@bg1, @bg2, @bg3]
end
- it "should find one group when searching for :description => 'find group-1'" do
+ it "finds matching groups when filtering on :description with text" do
@world.apply_inclusion_filters(@behaviours, :behaviour => { :description => 'find group-1' }).should == [@bg1]
end
- it "should find two groups when searching for :description => lambda { |v| v.include?('-1') || v.include?('-3') }" do
+ it "finds matching groups when filtering on :description with a lambda" do
@world.apply_inclusion_filters(@behaviours, :behaviour => { :description => lambda { |v| v.include?('-1') || v.include?('-3') } }).should == [@bg1, @bg3]
end
- it "should find three groups when searching for :description => /find group/" do
+ it "finds matching groups when filtering on :description with a regular expression" do
@world.apply_inclusion_filters(@behaviours, :behaviour => { :description => /find group/ }).should == [@bg1, @bg2, @bg3]
end
- it "should find one group when searching for :foo => 1" do
- @world.apply_inclusion_filters(@behaviours, :foo => 1 ).should == [@bg1]
- end
-
- it "should find one group when searching for :pending => true" do
+ it "finds one group when searching for :pending => true" do
@world.apply_inclusion_filters(@behaviours, :pending => true ).should == [@bg2]
end
- it "should find one group when searching for :array => [1,2,3,4]" do
+ it "finds matching groups when filtering on arbitrary metadata with a number" do
+ @world.apply_inclusion_filters(@behaviours, :foo => 1 ).should == [@bg1]
+ end
+
+ it "finds matching groups when filtering on arbitrary metadata with an array" do
@world.apply_inclusion_filters(@behaviours, :array => [1,2,3,4]).should == [@bg3]
end
- it "should find no group when searching for :array => [4,3,2,1]" do
+ it "finds no groups when filtering on arbitrary metadata with an array but the arrays do not match" do
@world.apply_inclusion_filters(@behaviours, :array => [4,3,2,1]).should be_empty
end
- it "should find two groups when searching for :color => 'blue'" do
- @world.apply_inclusion_filters(@behaviours, :color => 'blue').should == [@bg1, @bg3]
- end
-
- it "should find two groups when searching for :feature => 'reporting' }" do
- @world.apply_inclusion_filters(@behaviours, :feature => 'reporting').should == [@bg1, @bg2]
+ it "finds matching examples when filtering on arbitrary metadata" do
+ @world.apply_inclusion_filters(@bg4.examples, :awesome => true).should == [@bg4.examples[1], @bg4.examples[2]]
end
-
+
end
describe "applying exclusion filters" do
View
@@ -1,23 +1,18 @@
-dir = File.dirname(__FILE__)
-lib_path = File.expand_path("#{dir}/../lib")
-$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
+$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
+require 'rspec/core'
require 'rubygems'
-$LOAD_PATH.unshift(File.expand_path('../../../expectations/lib'), __FILE__)
+$LOAD_PATH << File.expand_path('../../../expectations/lib', __FILE__)
+$LOAD_PATH << File.expand_path('../../../mocks/lib', __FILE__)
require 'rspec/expectations'
-$LOAD_PATH.unshift(File.expand_path('../../../mocks/lib'), __FILE__)
require 'rspec/mocks'
-$LOAD_PATH.unshift(File.expand_path('../../lib'), __FILE__)
-require 'rspec/core'
Rspec::Core::ExampleGroup.send(:include, Rspec::Matchers)
def with_ruby(version)
yield if RUBY_PLATFORM =~ Regexp.compile("^#{version}")
end
-require 'rubygems'
-
module Rspec
module Core
module Matchers
@@ -70,7 +65,7 @@ def not_in_editor?
Rspec::Core.configure do |c|
c.mock_framework = :rspec
- # TODO: Filter run needs normal before/after/include filter logic
c.filter_run :focused => true
+ c.run_all_when_everything_filtered = true
c.color_enabled = not_in_editor?
end

0 comments on commit e4f1c40

Please sign in to comment.