Sha256: d8913c5024bd982aa04a52fcac2317e6c1ac4a172e7f14213b3d5c57e142eceb
Contents?: true
Size: 1.1 KB
Versions: 7
Compression:
Stored size: 1.1 KB
Contents
module RSpec module GraphqlMatchers class AcceptArguments attr_reader :actual_field, :expected_args def initialize(expected_args) @expected_args = expected_args end def matches?(actual_field) @actual_field = actual_field @expected_args.all? do |arg_name, arg_type| matches_argument?(arg_name, arg_type) end end def failure_message "expected field '#{field_name(actual_field)}' to accept arguments "\ "#{describe_arguments(expected_args)}" end def description "accept arguments #{describe_arguments(expected_args)}" end private def matches_argument?(arg_name, arg_type) actual_arg = actual_field.arguments[arg_name.to_s] actual_arg && actual_arg.type.to_s == arg_type.to_s end def describe_arguments(what_args) what_args.sort.map do |arg_name, arg_type| "#{arg_name}(#{arg_type})" end.join(', ') end def field_name(field) field.respond_to?(:name) && field.name || field.inspect end end end end
Version data entries
7 entries across 7 versions & 1 rubygems