Class: RSpec::GraphqlAssistant::Matchers::Match
- Inherits:
-
Object
- Object
- RSpec::GraphqlAssistant::Matchers::Match
- Includes:
- MatcherHelper
- Defined in:
- lib/rspec/graphql_assistant/matchers/match.rb
Instance Attribute Summary collapse
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#sample ⇒ Object
readonly
Returns the value of attribute sample.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(key, expected, **args) ⇒ Match
constructor
A new instance of Match.
- #matches?(actual) ⇒ Boolean
Methods included from MatcherHelper
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
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
7 8 9 |
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 7 def expected @expected end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 7 def key @key end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
7 8 9 |
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 7 def root @root end |
#sample ⇒ Object (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
#description ⇒ Object
25 26 27 |
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 25 def description "'#{key}' match '#{expected}'" end |
#failure_message ⇒ Object
21 22 23 |
# File 'lib/rspec/graphql_assistant/matchers/match.rb', line 21 def "'#{key}' not match '#{expected}'" end |
#matches?(actual) ⇒ 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 |