class Mocha::ParameterMatchers::HasEntries
Parameter matcher which matches when actual parameter contains all expected Hash
entries.
def initialize(entries, exact: false)
- Private: -
def initialize(entries, exact: false) @entries = entries @exact = exact end
def matches?(available_parameters)
- Private: -
def matches?(available_parameters) parameter = available_parameters.shift return false unless parameter return false unless parameter.respond_to?(:keys) return false if @exact && @entries.length != parameter.keys.length has_entry_matchers = @entries.map { |key, value| HasEntry.new(key, value) } AllOf.new(*has_entry_matchers).matches?([parameter]) end
def mocha_inspect
- Private: -
def mocha_inspect @exact ? @entries.mocha_inspect : "has_entries(#{@entries.mocha_inspect})" end