Class: RSpec::GraphqlMatchers::HaveAFieldMatchers::WithHashKey

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_hash_key) ⇒ WithHashKey

Returns a new instance of WithHashKey.



7
8
9
# File 'lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb', line 7

def initialize(expected_hash_key)
  @expected_hash_key = expected_hash_key
end

Instance Method Details

#descriptionObject



11
12
13
# File 'lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb', line 11

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

#failure_messageObject



20
21
22
# File 'lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb', line 20

def failure_message
  "#{description}, but it was `#{@actual_hash_key}`"
end

#matches?(actual_field) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/rspec/graphql_matchers/have_a_field_matchers/with_hash_key.rb', line 15

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