Sha256: a3360efa3ecb7d073918eab4f07b3faa092eaa640761ecc391bca947f0db0c1f

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 Bytes

Contents

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 = 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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-graphql_matchers-1.0 lib/rspec/graphql_matchers/be_of_type.rb