Permalink
Browse files

metadata supports arrays for procs as well

  • Loading branch information...
weidenfreak
weidenfreak committed Dec 27, 2011
1 parent af8d17c commit 2332f34a6351b1a18bb69cde605db99263583b63
Showing with 9 additions and 1 deletion.
  1. +1 −1 lib/rspec/core/metadata.rb
  2. +8 −0 spec/rspec/core/metadata_spec.rb
@@ -169,7 +169,7 @@ def all_apply?(filters)
# @private
def filter_applies?(key, value, metadata=self)
- return metadata.filter_applies_to_any_value?(key, value) if Array === metadata[key]
+ return metadata.filter_applies_to_any_value?(key, value) if Array === metadata[key] && !(Proc === value)
return metadata.line_number_filter_applies?(value) if key == :line_numbers
return metadata.location_filter_applies?(value) if key == :locations
return metadata.filters_apply?(key, value) if Hash === value
@@ -160,6 +160,14 @@ module Core
metadata_with_array.filter_applies?(:tag, 'fourtune').should be_true
metadata_with_array.filter_applies?(:tag, 'fortune').should be_false
end
+
+ it "matches a proc that evaluates to true" do
+ metadata_with_array.filter_applies?(:tag, lambda { |values| values.include? 'three' }).should be_true
+ end
+
+ it "does not match a proc that evaluates to false" do
+ metadata_with_array.filter_applies?(:tag, lambda { |values| values.include? 'nothing' }).should be_false
+ end
end
end

0 comments on commit 2332f34

Please sign in to comment.