Sha256: 7cb6be2088c231621e058c34d0667993da245c567f74152ba2cb99be08f62f76

Contents?: true

Size: 801 Bytes

Versions: 4

Compression:

Stored size: 801 Bytes

Contents

module RSpec
  module GraphqlMatchers
    module HaveAFieldMatchers
      class WithProperty
        def initialize(expected_property_name)
          @expected_property_name = expected_property_name
        end

        def description
          "resolving with property `#{@expected_property_name}`"
        end

        def matches?(actual_field)
          @actual_property = property(actual_field).to_sym
          @actual_property == @expected_property_name.to_sym
        end

        def failure_message
          "#{description}, but it was `#{@actual_property}`"
        end

        private

        def property(field)
          property = field.property
          property = field.metadata[:type_class].method_sym if property.nil?
          property
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-graphql_matchers-1.3.0 lib/rspec/graphql_matchers/have_a_field_matchers/with_property.rb
rspec-graphql_matchers-1.2.1 lib/rspec/graphql_matchers/have_a_field_matchers/with_property.rb
rspec-graphql_matchers-1.2 lib/rspec/graphql_matchers/have_a_field_matchers/with_property.rb
rspec-graphql_matchers-1.1 lib/rspec/graphql_matchers/have_a_field_matchers/with_property.rb