class Mocha::ParameterMatchers::HasKeys
Parameter matcher which matches when actual parameter contains Hash
with all expected keys.
def initialize(*keys)
- Private: -
def initialize(*keys) raise ArgumentError, 'No arguments. Expecting at least one.' if keys.empty? @keys = keys end
def matches?(available_parameters)
- Private: -
def matches?(available_parameters) parameter = available_parameters.shift return false unless parameter.respond_to?(:keys) @keys.map(&:to_matcher).all? do |matcher| parameter.keys.any? { |key| matcher.matches?([key]) } end end
def mocha_inspect
- Private: -
def mocha_inspect "has_keys(#{@keys.mocha_inspect(false)})" end