Sha256: 44418d9cb64ed761d2802e8509b55a5c2828043a99ee4a4dad6274fbb0cbd8c3

Contents?: true

Size: 604 Bytes

Versions: 1

Compression:

Stored size: 604 Bytes

Contents

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 = actual_sample
        sample.respond_to?(:type) && sample.type.to_s == @expected.to_s
      end

      def failure_message
        "expected field '#{member_name(sample)}' to be of type '#{expected}', " \
        "but it was '#{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.0.pre.0.1 lib/rspec/graphql_matchers/be_of_type.rb