Skip to content
Browse files

Merge pull request #535 from AlexKVal/meta3

#prune tests with the double
  • Loading branch information...
2 parents a7d6acd + d6b1dbc commit 4b91fa0f15c2ea12ee482486933410b11a229f0e @dchelimsky dchelimsky committed Dec 8, 2011
Showing with 18 additions and 12 deletions.
  1. +18 −12 spec/rspec/core/filter_manager_spec.rb
View
30 spec/rspec/core/filter_manager_spec.rb
@@ -83,52 +83,58 @@ def opposite(name)
end
describe "#prune" do
+ def filterable_object_with(args = {})
+ object = double('a filterable object')
+ object.stub(:any_apply?) { |f| Metadata.new(args).any_apply?(f) }
+ object
+ end
+
it "includes objects with tags matching inclusions" do
- included = RSpec::Core::Metadata.new({:foo => :bar})
- excluded = RSpec::Core::Metadata.new
+ included = filterable_object_with({:foo => :bar})
+ excluded = filterable_object_with
filter_manager = FilterManager.new
filter_manager.include :foo => :bar
filter_manager.prune([included, excluded]).should eq([included])
end
it "excludes objects with tags matching exclusions" do
- included = RSpec::Core::Metadata.new
- excluded = RSpec::Core::Metadata.new({:foo => :bar})
+ included = filterable_object_with
+ excluded = filterable_object_with({:foo => :bar})
filter_manager = FilterManager.new
filter_manager.exclude :foo => :bar
filter_manager.prune([included, excluded]).should eq([included])
end
it "prefers exclusion when matches previously set inclusion" do
- included = RSpec::Core::Metadata.new
- excluded = RSpec::Core::Metadata.new({:foo => :bar})
+ included = filterable_object_with
+ excluded = filterable_object_with({:foo => :bar})
filter_manager = FilterManager.new
filter_manager.include :foo => :bar
filter_manager.exclude :foo => :bar
filter_manager.prune([included, excluded]).should eq([included])
end
it "prefers inclusion when matches previously set exclusion" do
- included = RSpec::Core::Metadata.new({:foo => :bar})
- excluded = RSpec::Core::Metadata.new
+ included = filterable_object_with({:foo => :bar})
+ excluded = filterable_object_with
filter_manager = FilterManager.new
filter_manager.exclude :foo => :bar
filter_manager.include :foo => :bar
filter_manager.prune([included, excluded]).should eq([included])
end
it "prefers previously set inclusion when exclusion matches but has lower priority" do
- included = RSpec::Core::Metadata.new({:foo => :bar})
- excluded = RSpec::Core::Metadata.new
+ included = filterable_object_with({:foo => :bar})
+ excluded = filterable_object_with
filter_manager = FilterManager.new
filter_manager.include :foo => :bar
filter_manager.exclude_with_low_priority :foo => :bar
filter_manager.prune([included, excluded]).should eq([included])
end
it "prefers previously set exclusion when inclusion matches but has lower priority" do
- included = RSpec::Core::Metadata.new
- excluded = RSpec::Core::Metadata.new({:foo => :bar})
+ included = filterable_object_with
+ excluded = filterable_object_with({:foo => :bar})
filter_manager = FilterManager.new
filter_manager.exclude :foo => :bar
filter_manager.include_with_low_priority :foo => :bar

0 comments on commit 4b91fa0

Please sign in to comment.
Something went wrong with that request. Please try again.