Sha256: 0217b2290a7266738aa1f3a217f09af4b9a4430afd4bb933b2e9e9b1c55b6aba

Contents?: true

Size: 667 Bytes

Versions: 1

Compression:

Stored size: 667 Bytes

Contents

module RSpec
  module GraphqlMatchers
    module HaveAFieldMatchers
      class WithHashKey
        def initialize(expected_hash_key)
          @expected_hash_key = expected_hash_key
        end

        def description
          "with hash key `#{@expected_hash_key}`"
        end

        def matches?(actual_field)
          get_hash_key(actual_field) == @expected_hash_key.to_sym
        end

        private

        def get_hash_key(actual_field)
          if actual_field.respond_to?(:hash_key)
            return actual_field.hash_key.to_sym
          end

          # Class-based api
          actual_field.method_sym
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-graphql_matchers-1.0.0.pre.0.1 lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb