Class: RSpec::GraphqlAssistant::Matchers::Match

Inherits:
Object
  • Object
show all
Includes:
MatcherHelper
Defined in:
lib/rspec/graphql_assistant/matchers/match.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MatcherHelper

#key_to_array, #lookup_value

Constructor Details

#initialize(key, expected, **args) ⇒ Match

Returns a new instance of Match.



9
10
11
12
13
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 9

def initialize(key, expected, **args)
  @key = key
  @expected = expected
  @root = args.fetch(:root, :data)
end

Instance Attribute Details

#expectedObject (readonly)

Returns the value of attribute expected.



7
8
9
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 7

def expected
  @expected
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 7

def key
  @key
end

#rootObject (readonly)

Returns the value of attribute root.



7
8
9
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 7

def root
  @root
end

#sampleObject (readonly)

Returns the value of attribute sample.



7
8
9
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 7

def sample
  @sample
end

Instance Method Details

#descriptionObject



25
26
27
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 25

def description
  "'#{key}' match '#{expected}'"
end

#failure_messageObject



21
22
23
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 21

def failure_message
  "'#{key}' not match '#{expected}'"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 15

def matches?(actual)
  value = lookup_value(actual)

  value == expected
end