class RSpec::GraphqlAssistant::Matchers::HaveAttributes
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/have_attributes.rb, line 9 def initialize(key, expected, **args) @key = key @expected = expected @root = args.fetch(:root, :data) end
Public Instance Methods
description()
click to toggle source
# File lib/rspec/graphql_assistant/matchers/have_attributes.rb, line 35 def description "'#{key}' has attributes '#{expected}'" end
expected_hash(value, expected)
click to toggle source
# File lib/rspec/graphql_assistant/matchers/have_attributes.rb, line 22 def expected_hash(value, expected) res = true expected.each do |k, v| res = value[k] == v break unless res end res end
failure_message()
click to toggle source
# File lib/rspec/graphql_assistant/matchers/have_attributes.rb, line 31 def failure_message "'#{key}' not equal attributes '#{expected}'" end
matches?(actual)
click to toggle source
# File lib/rspec/graphql_assistant/matchers/have_attributes.rb, line 15 def matches?(actual) value = lookup_value(actual) return expected_hash(value, expected) if expected.is_a?(Hash) false end