Class: Mocha::ParameterMatchers::HasEntries

Inherits:
Base
  • Object
show all
Defined in:
lib/mocha/parameter_matchers/has_entries.rb

Overview

Parameter matcher which matches when actual parameter contains all expected Hash entries.

Instance Method Summary collapse

Methods inherited from Base

#&, #to_matcher, #|

Constructor Details

#initialize(entries) ⇒ HasEntries


35
36
37
# File 'lib/mocha/parameter_matchers/has_entries.rb', line 35

def initialize(entries)
  @entries = entries
end

Instance Method Details

#matches?(available_parameters) ⇒ Boolean


40
41
42
43
44
# File 'lib/mocha/parameter_matchers/has_entries.rb', line 40

def matches?(available_parameters)
  parameter = available_parameters.shift
  has_entry_matchers = @entries.map { |key, value| HasEntry.new(key, value) }
  AllOf.new(*has_entry_matchers).matches?([parameter])
end

#mocha_inspectObject


47
48
49
# File 'lib/mocha/parameter_matchers/has_entries.rb', line 47

def mocha_inspect
  "has_entries(#{@entries.mocha_inspect})"
end