Sha256: 791e5d618aec73ce3120f18032b94c1affe8bc9d3bb6de38e1498347d86ad432

Contents?: true

Size: 929 Bytes

Versions: 13

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true

require 'grpc_mock/matchers/hash_argument_matcher'

module GrpcMock
  module Matchers
    class RequestIncludingMatcher < HashArgumentMatcher
      def ==(actual)
        if actual.respond_to?(:to_h)
          actual = actual.to_h
        end

        actual = Hash[GrpcMock::Matchers::HashArgumentMatcher.stringify_keys!(actual, deep: true)]
        super { |key, value| inner_including(value, key, actual) }
      rescue NoMethodError
        false
      end

      private

      def inner_including(expect, key, actual)
        if actual.key?(key)
          actual_value = actual[key]
          if expect.is_a?(Hash)
            RequestIncludingMatcher.new(expect) == actual_value
          else
            expect === actual_value
          end
        else
          false
        end
      end

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

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/grpc_mock-0.4.6/lib/grpc_mock/matchers/request_including_matcher.rb
grpc_mock-0.4.6 lib/grpc_mock/matchers/request_including_matcher.rb
grpc_mock-0.4.5 lib/grpc_mock/matchers/request_including_matcher.rb
grpc_mock-0.4.4 lib/grpc_mock/matchers/request_including_matcher.rb
grpc_mock-0.4.3 lib/grpc_mock/matchers/request_including_matcher.rb
grpc_mock-0.4.2 lib/grpc_mock/matchers/request_including_matcher.rb
grpc_mock-0.4.1 lib/grpc_mock/matchers/request_including_matcher.rb
gruffish-0.5.0.pre1 lib/grpc_mock/matchers/request_including_matcher.rb
grpc_mock-0.4.0 lib/grpc_mock/matchers/request_including_matcher.rb
grpc_mock-0.3.1 lib/grpc_mock/matchers/request_including_matcher.rb
grpc_mock-0.3.0 lib/grpc_mock/matchers/request_including_matcher.rb
grpc_mock-0.2.2 lib/grpc_mock/matchers/request_including_matcher.rb
grpc_mock-0.2.1 lib/grpc_mock/matchers/request_including_matcher.rb