Method: RSpec::Mocks::ArgumentMatchers#hash_including

Defined in:
lib/rspec/mocks/argument_matchers.rb

#hash_including(*args) ⇒ Object

Matches a hash that includes the specified key(s) or key/value pairs. Ignores any additional keys.

Examples:


expect(object).to receive(:message).with(hash_including(:key => val))
expect(object).to receive(:message).with(hash_including(:key))
expect(object).to receive(:message).with(hash_including(:key, :key2 => val2))


72
73
74
# File 'lib/rspec/mocks/argument_matchers.rb', line 72

def hash_including(*args)
  HashIncludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args))
end

Comments