Sha256: ab6a197511c01a3c2c088d44a81da417cd41a2118661fb7ccb578dcebf840030

Contents?: true

Size: 896 Bytes

Versions: 10

Compression:

Stored size: 896 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

    #this is a based on RSpec::Mocks::ArgumentMatchers::AnyArgMatcher
    class AnyArgMatcher
      def initialize(ignore)
      end

      def ==(other)
        true
      end
    end

  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
whos_dated_who-0.1.0 vendor/bundle/gems/webmock-1.18.0/lib/webmock/matchers/hash_including_matcher.rb
whos_dated_who-0.0.1 vendor/bundle/gems/webmock-1.18.0/lib/webmock/matchers/hash_including_matcher.rb
webmock-1.18.0 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.17.4 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.17.3 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.17.2 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.17.1 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.17.0 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.16.1 lib/webmock/matchers/hash_including_matcher.rb
webmock-1.16.0 lib/webmock/matchers/hash_including_matcher.rb