Sha256: 243a7b35c696694ec5b21f6956442136efa61cec375c682f0a827434aa660261
Contents?: true
Size: 976 Bytes
Versions: 50
Compression:
Stored size: 976 Bytes
Contents
module Mocha module ParameterMatchers # :call-seq: has_entry(key, value) -> parameter_matcher # # Matches +Hash+ containing entry with +key+ and +value+. # object = mock() # object.expects(:method_1).with(has_entry('key_1', 1)) # object.method_1('key_1' => 1, 'key_2' => 2) # # no error raised # # object = mock() # object.expects(:method_1).with(has_entry('key_1', 1)) # object.method_1('key_1' => 2, 'key_2' => 1) # # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1 def has_entry(key, value) HasEntry.new(key, value) end class HasEntry # :nodoc: def initialize(key, value) @key, @value = key, value end def ==(parameter) parameter[@key] == @value end def mocha_inspect "has_entry(#{@key.mocha_inspect}, #{@value.mocha_inspect})" end end end end
Version data entries
50 entries across 50 versions & 4 rubygems