Skip to content
This repository
Browse code

Refactoring: Hash is a special case too

- #504.
  • Loading branch information...
commit 5e54d7651312b67d4ef6c988b93f1771a1c65c79 1 parent de1dffa
David Chelimsky dchelimsky authored

Showing 1 changed file with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. +6 2 lib/rspec/core/metadata.rb
8 lib/rspec/core/metadata.rb
@@ -172,10 +172,9 @@ def filter_applies?(key, value, metadata=self)
172 172 return metadata.filter_applies_to_any_value?(key, value) if Array === metadata[key]
173 173 return metadata.line_number_filter_applies?(value) if key == :line_numbers
174 174 return metadata.location_filter_applies?(value) if key == :locations
  175 + return metadata.filters_apply?(key, value) if Hash === value
175 176
176 177 case value
177   - when Hash
178   - value.all? {|k, v| filter_applies?(k, v, metadata[key])}
179 178 when Regexp
180 179 metadata[key] =~ value
181 180 when Proc
@@ -196,6 +195,11 @@ def filter_applies?(key, value, metadata=self)
196 195 end
197 196
198 197 # @private
  198 + def filters_apply?(key, value)
  199 + value.all? {|k, v| filter_applies?(k, v, self[key])}
  200 + end
  201 +
  202 + # @private
199 203 def filter_applies_to_any_value?(key, value)
200 204 self[key].any? {|v| filter_applies?(key, v, {key => value})}
201 205 end

0 comments on commit 5e54d76

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