lib/rspec/graphql_matchers/implement.rb in rspec-graphql_matchers-0.7.1 vs lib/rspec/graphql_matchers/implement.rb in rspec-graphql_matchers-1.0.0.pre.0.1

- old
+ new

@@ -8,13 +8,11 @@ end def matches?(graph_object) @graph_object = graph_object @actual = actual - @expected.each do |name| - return false unless @actual.include?(name) - end + @expected.all? { |name| @actual.include?(name) } end def failure_message message = "expected interfaces: #{@expected.join(', ')}\n" message += "actual interfaces: #{@actual.join(', ')}" @@ -33,14 +31,22 @@ private def actual if @graph_object.respond_to?(:interfaces) - @graph_object.interfaces.map(&:to_s) + @graph_object.interfaces.map do |interface| + interface_name(interface) + end else raise "Invalid object #{@graph_object} provided to #{matcher_name} " \ 'matcher. It does not seem to be a valid GraphQL object type.' end + end + + def interface_name(interface) + return interface.graphql_name if interface.respond_to?(:graphql_name) + + interface.to_s end end end end