Sha256: 1ac9b8c95311c0fe8c4dce40fc210266f1dfab4bace2fa58f23077aee9ba980c
Contents?: true
Size: 841 Bytes
Versions: 1
Compression:
Stored size: 841 Bytes
Contents
# frozen_string_literal: true require_relative 'base_matcher' require 'pry' 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rspec-graphql_matchers-1.0.1 | lib/rspec/graphql_matchers/be_of_type.rb |