Sha256: 1299f71ea001df5159edb82e0b9679be033b0f8ccc9c4a29e0eb0a08e1066be1
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
require_relative 'base_matcher' module RSpec module GraphqlMatchers class Implement < BaseMatcher def initialize(interface_names) @expected = interface_names.map(&:to_s) end def matches?(graph_object) @graph_object = graph_object @actual = actual @expected.each do |name| return false unless @actual.include?(name) end end def failure_message message = "expected interfaces: #{@expected.join(', ')}\n" message += "actual interfaces: #{@actual.join(', ')}" message end def failure_message_when_negated message = "unexpected interfaces: #{@expected.join(', ')}\n" message += "actual interfaces: #{@actual.join(', ')}" message end def description "implement #{@expected.join(', ')}" end private def actual if @graph_object.respond_to?(:interfaces) @graph_object.interfaces.map(&:to_s) else raise "Invalid object #{@graph_object} provided to #{matcher_name} " \ 'matcher. It does not seem to be a valid GraphQL object type.' end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rspec-graphql_matchers-0.7.1 | lib/rspec/graphql_matchers/implement.rb |
rspec-graphql_matchers-0.6 | lib/rspec/graphql_matchers/implement.rb |