Sha256: bd9573299021668ac080b1e1d3a60f75298f22522f9e7fe5d299acce7528c3c6

Contents?: true

Size: 709 Bytes

Versions: 33

Compression:

Stored size: 709 Bytes

Contents

module WebMock
  module Matchers
    #this is a based on RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher
    #https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/argument_matchers.rb
    class HashIncludingMatcher
      def initialize(expected)
        @expected = Hash[WebMock::Util::HashKeysStringifier.stringify_keys!(expected).sort]
      end

      def ==(actual)
        @expected.all? {|k,v| actual.has_key?(k) && v == actual[k]}
      rescue NoMethodError
        false
      end

      def inspect
        "hash_including(#{@expected.inspect})"
      end

      def self.from_rspec_matcher(matcher)
        new(matcher.instance_variable_get(:@expected))
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 3 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/webmock-1.8.11/lib/webmock/matchers/hash_including_matcher.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/webmock-1.8.11/lib/webmock/matchers/hash_including_matcher.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/webmock-1.8.11/lib/webmock/matchers/hash_including_matcher.rb
webmock-1.15.2 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.15.0 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.14.0 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.13.0 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.12.3 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.12.2 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.12.1 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.12.0 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.11.0 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.10.2 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.10.1 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.10.0 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.9.3 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.9.2 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.9.1 lib/webmock/matchers/hash_including_matcher.rb
simple-client-0.0.3 vendor/bundle/ruby/1.9.1/gems/webmock-1.8.8/lib/webmock/matchers/hash_including_matcher.rb
webmock-1.9.0 lib/webmock/matchers/hash_including_matcher.rb