class WebMock::Matchers::HashIncludingMatcher

this is a based on RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/argument_matchers.rb

Public Class Methods

from_rspec_matcher(matcher) click to toggle source
# File lib/webmock/matchers/hash_including_matcher.rb, line 20
def self.from_rspec_matcher(matcher)
  new(matcher.instance_variable_get(:@expected))
end
new(expected) click to toggle source
# File lib/webmock/matchers/hash_including_matcher.rb, line 6
def initialize(expected)
  @expected = Hash[WebMock::Util::HashKeysStringifier.stringify_keys!(expected, deep: true).sort]
end

Public Instance Methods

==(actual) click to toggle source
# File lib/webmock/matchers/hash_including_matcher.rb, line 10
def ==(actual)
  @expected.all? {|k,v| actual.has_key?(k) && v === actual[k]}
rescue NoMethodError
  false
end
inspect() click to toggle source
# File lib/webmock/matchers/hash_including_matcher.rb, line 16
def inspect
  "hash_including(#{@expected.inspect})"
end