class RSpec::GraphqlMatchers::HaveAFieldMatchers::WithHashKey
Public Class Methods
new(expected_hash_key)
click to toggle source
# File lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb, line 5 def initialize(expected_hash_key) @expected_hash_key = expected_hash_key end
Public Instance Methods
description()
click to toggle source
# File lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb, line 9 def description "with hash key `#{@expected_hash_key}`" end
failure_message()
click to toggle source
# File lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb, line 18 def failure_message "#{description}, but it was `#{@actual_hash_key}`" end
matches?(actual_field)
click to toggle source
# File lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb, line 13 def matches?(actual_field) @actual_hash_key = get_hash_key(actual_field) @actual_hash_key == @expected_hash_key.to_sym end
Private Instance Methods
get_hash_key(actual_field)
click to toggle source
# File lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb, line 24 def get_hash_key(actual_field) if actual_field.respond_to?(:hash_key) return actual_field.hash_key.to_sym if actual_field.hash_key end actual_field.metadata[:type_class].method_sym end