Sha256: ecaa7dd51a6fefabeab69f65cf3c62871c75fae3cee00225a4e053ab9e6a81da

Contents?: true

Size: 606 Bytes

Versions: 12

Compression:

Stored size: 606 Bytes

Contents

# frozen_string_literal: true

module WebMock
  module Matchers
    # Base class for Hash matchers
    # https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/argument_matchers.rb
    class HashArgumentMatcher
      def initialize(expected)
        @expected = Hash[WebMock::Util::HashKeysStringifier.stringify_keys!(expected, deep: true).sort]
      end

      def ==(_actual, &block)
        @expected.all?(&block)
      rescue NoMethodError
        false
      end

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

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
webmock-3.24.0 lib/webmock/matchers/hash_argument_matcher.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/webmock-3.23.1/lib/webmock/matchers/hash_argument_matcher.rb
webmock-3.23.0 lib/webmock/matchers/hash_argument_matcher.rb
webmock-3.22.0 lib/webmock/matchers/hash_argument_matcher.rb
webmock-3.21.2 lib/webmock/matchers/hash_argument_matcher.rb
webmock-3.21.1 lib/webmock/matchers/hash_argument_matcher.rb
webmock-3.21.0 lib/webmock/matchers/hash_argument_matcher.rb
webmock-3.20.0 lib/webmock/matchers/hash_argument_matcher.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/webmock-3.19.1/lib/webmock/matchers/hash_argument_matcher.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/webmock-3.19.1/lib/webmock/matchers/hash_argument_matcher.rb
webmock-3.19.1 lib/webmock/matchers/hash_argument_matcher.rb
webmock-3.19.0 lib/webmock/matchers/hash_argument_matcher.rb