Skip to content

Commit

Permalink
add filter_run_excluding
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Jun 14, 2010
1 parent bf5a6c4 commit 2dc6eee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/rspec/core/configuration.rb
Expand Up @@ -213,10 +213,16 @@ def alias_example_to(new_name, extra_options={})
RSpec::Core::ExampleGroup.alias_example_to(new_name, extra_options)
end

def filter_run(options={})
def filter_run_including(options={})
self.filter = options unless filter and filter[:line_number] || filter[:full_description]
end

alias_method :filter_run, :filter_run_including

def filter_run_excluding(options={})
self.exclusion_filter = options
end

def include(mod, filters={})
include_or_extend_modules << [:include, mod, filters]
end
Expand Down
14 changes: 14 additions & 0 deletions spec/rspec/core/configuration_spec.rb
Expand Up @@ -252,6 +252,20 @@ def that_thing

end

describe "#filter_run" do
it "sets the filter" do
config.filter_run :focus => true
config.filter.should eq({:focus => true})
end
end

describe "#filter_run_excluding" do
it "sets the filter" do
config.filter_run_excluding :slow => true
config.exclusion_filter.should eq({:slow => true})
end
end

describe "line_number=" do
it "sets the line number" do
config.line_number = '37'
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Expand Up @@ -54,9 +54,9 @@ def in_editor?
c.color_enabled = !in_editor?
c.filter_run :focus => true
c.run_all_when_everything_filtered = true
c.exclusion_filter = { :ruby => lambda {|version|
c.filter_run_excluding :ruby => lambda {|version|
!(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
}}
}
c.before(:each) do
@real_world = RSpec.world
RSpec.instance_variable_set(:@world, RSpec::Core::World.new)
Expand Down

0 comments on commit 2dc6eee

Please sign in to comment.