Class: RSpec::GraphqlAssistant::Matchers::Include
- Inherits:
-
Object
- Object
- RSpec::GraphqlAssistant::Matchers::Include
- Includes:
- MatcherHelper
- Defined in:
- lib/rspec/graphql_assistant/matchers/include.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) ⇒ Include
constructor
A new instance of Include.
- #matches?(actual) ⇒ Boolean
Methods included from MatcherHelper
Constructor Details
#initialize(key, expected, **args) ⇒ Include
Returns a new instance of Include.
8 9 10 11 12 |
# File 'lib/rspec/graphql_assistant/matchers/include.rb', line 8 def initialize(key, expected, **args) @expected = expected @key = key @root = args.fetch(:root, :data) end |
Instance Attribute Details
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
6 7 8 |
# File 'lib/rspec/graphql_assistant/matchers/include.rb', line 6 def expected @expected end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
6 7 8 |
# File 'lib/rspec/graphql_assistant/matchers/include.rb', line 6 def key @key end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
6 7 8 |
# File 'lib/rspec/graphql_assistant/matchers/include.rb', line 6 def root @root end |
#sample ⇒ Object (readonly)
Returns the value of attribute sample.
6 7 8 |
# File 'lib/rspec/graphql_assistant/matchers/include.rb', line 6 def sample @sample end |
Instance Method Details
#description ⇒ Object
26 27 28 |
# File 'lib/rspec/graphql_assistant/matchers/include.rb', line 26 def description "'#{key}' has attributes '#{expected}'" end |
#failure_message ⇒ Object
22 23 24 |
# File 'lib/rspec/graphql_assistant/matchers/include.rb', line 22 def "'#{key}' not include all attributes '#{expected}'" end |
#matches?(actual) ⇒ Boolean
14 15 16 17 18 19 20 |
# File 'lib/rspec/graphql_assistant/matchers/include.rb', line 14 def matches?(actual) value = lookup_value(actual) return value.any? { |k, _v| expected.include? k } if value.is_a?(Hash) value.all? { |el| el.any? { |k, _v| expected.include? k } } if value.is_a?(Array) end |