Permalink
Browse files

more concise FilterManager#update

  • Loading branch information...
1 parent cf41edb commit 90e56a913fd73d4c9dc50f75d90d09761426af89 Sasha committed Dec 1, 2011
Showing with 9 additions and 10 deletions.
  1. +6 −7 lib/rspec/core/filter_manager.rb
  2. +3 −3 spec/rspec/core/filter_manager_spec.rb
@@ -146,13 +146,12 @@ def include(*args)
end
def update(orig, opposite, *updates)
- if updates.length == 2
- if updates[0] == :replace
- updated = updates.last
- else
- updated = updates.last.merge(orig)
- opposite.each_key {|k| updated.delete(k)}
- end
+ case updates.first
+ when :replace
+ orig.replace(updates.last)
+ when :low_priority
+ updated = updates.last.merge(orig)
+ opposite.each_key {|k| updated.delete(k)}
orig.replace(updated)
else
orig.merge!(updates.last).each_key {|k| opposite.delete(k)}
@@ -23,7 +23,7 @@ module RSpec::Core
filter_manager = FilterManager.new
filter_manager.exclusions.clear # defaults
filter_manager.send name, :foo => 1
- filter_manager.send name, :weak, :foo => 2
+ filter_manager.send name, :low_priority, :foo => 2
filter_manager.send(type).should eq(:foo => 1)
end
end
@@ -68,7 +68,7 @@ module RSpec::Core
excluded = RSpec::Core::Metadata.new
filter_manager = FilterManager.new
filter_manager.include :foo => :bar
- filter_manager.exclude :low, :foo => :bar
+ filter_manager.exclude :low_priority, :foo => :bar
filter_manager.prune([included, excluded]).should eq([included])
end
@@ -77,7 +77,7 @@ module RSpec::Core
excluded = RSpec::Core::Metadata.new({:foo => :bar})
filter_manager = FilterManager.new
filter_manager.exclude :foo => :bar
- filter_manager.include :low, :foo => :bar
+ filter_manager.include :low_priority, :foo => :bar
filter_manager.prune([included, excluded]).should eq([included])
end
end

0 comments on commit 90e56a9

Please sign in to comment.