Sha256: 05e31b925da664df6ef46a6cbc8e4c28adb7ce2feda4a39ac75597c23cf6c24b
Contents?: true
Size: 827 Bytes
Versions: 5
Compression:
Stored size: 827 Bytes
Contents
# frozen_string_literal: true require_relative 'base_matcher' module RSpec module GraphqlMatchers class BeOfType < BaseMatcher attr_reader :sample, :expected def initialize(expected) @expected = expected end def matches?(actual_sample) @sample = to_graphql(actual_sample) sample.respond_to?(:type) && types_match?(sample.type, @expected) end def failure_message "expected field '#{member_name(sample)}' to be of type '#{expected}', " \ "but it was '#{type_name(sample.type)}'" end def description "be of type '#{expected}'" end private def to_graphql(field_sample) return field_sample unless field_sample.respond_to?(:to_graphql) field_sample.to_graphql end end end end
Version data entries
5 entries across 5 versions & 1 rubygems