Skip to content

Commit

Permalink
Merge pull request rspec#545 from weidenfreak/master
Browse files Browse the repository at this point in the history
metadata supports arrays for procs
  • Loading branch information
justinko committed Dec 27, 2011
2 parents af8d17c + 2332f34 commit aea82a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec/core/metadata.rb
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions spec/rspec/core/metadata_spec.rb
Expand Up @@ -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

Expand Down

0 comments on commit aea82a9

Please sign in to comment.