Permalink
Browse files

Refactoring: Hash is a special case too

- #504.
  • Loading branch information...
1 parent de1dffa commit 5e54d7651312b67d4ef6c988b93f1771a1c65c79 @dchelimsky dchelimsky committed Dec 18, 2011
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/rspec/core/metadata.rb
View
8 lib/rspec/core/metadata.rb
@@ -172,10 +172,9 @@ def filter_applies?(key, value, metadata=self)
return metadata.filter_applies_to_any_value?(key, value) if Array === metadata[key]
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
case value
- when Hash
- value.all? {|k, v| filter_applies?(k, v, metadata[key])}
when Regexp
metadata[key] =~ value
when Proc
@@ -196,6 +195,11 @@ def filter_applies?(key, value, metadata=self)
end
# @private
+ def filters_apply?(key, value)
+ value.all? {|k, v| filter_applies?(k, v, self[key])}
+ end
+
+ # @private
def filter_applies_to_any_value?(key, value)
self[key].any? {|v| filter_applies?(key, v, {key => value})}
end

0 comments on commit 5e54d76

Please sign in to comment.