class RSpec::GraphqlAssistant::Matchers::Include
Attributes
expected[R]
key[R]
root[R]
sample[R]
Public Class Methods
new(key, expected, **args)
click to toggle source
# 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
Public Instance Methods
description()
click to toggle source
# File lib/rspec/graphql_assistant/matchers/include.rb, line 26 def description "'#{key}' has attributes '#{expected}'" end
failure_message()
click to toggle source
# File lib/rspec/graphql_assistant/matchers/include.rb, line 22 def failure_message "'#{key}' not include all attributes '#{expected}'" end
matches?(actual)
click to toggle source
# 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