class Mocha::ParameterMatchers::HasEntry
Parameter matcher which matches when actual parameter contains expected Hash
entry.
def initialize(key, value)
- Private: -
def initialize(key, value) @key = key @value = value end
def matches?(available_parameters)
- Private: -
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
def mocha_inspect
- Private: -
def mocha_inspect "has_entry(#{@key.mocha_inspect} => #{@value.mocha_inspect})" end