Class: Mocha::ParameterMatchers::HasEntry
- Defined in:
- lib/mocha/parameter_matchers/has_entry.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(key, value) ⇒ HasEntry
constructor
A new instance of HasEntry.
- #matches?(available_parameters) ⇒ Boolean
- #mocha_inspect ⇒ Object
Methods inherited from Base
#&, #to_matcher, #|
Constructor Details
#initialize(key, value) ⇒ HasEntry
Returns a new instance of HasEntry.
38 39 40 |
# File 'lib/mocha/parameter_matchers/has_entry.rb', line 38 def initialize(key, value) @key, @value = key, value end |
Instance Method Details
#matches?(available_parameters) ⇒ Boolean
42 43 44 45 46 47 |
# File 'lib/mocha/parameter_matchers/has_entry.rb', line 42 def matches?(available_parameters) parameter = available_parameters.shift return false unless parameter.respond_to?(:keys) && parameter.respond_to?(:[]) matching_keys = parameter.keys.select { |key| @key.to_matcher.matches?([key]) } matching_keys.any? { |key| @value.to_matcher.matches?([parameter[key]]) } end |
#mocha_inspect ⇒ Object
49 50 51 |
# File 'lib/mocha/parameter_matchers/has_entry.rb', line 49 def mocha_inspect "has_entry(#{@key.mocha_inspect} => #{@value.mocha_inspect})" end |