Sha256: 0474c878a864b33f0773f09506da3c3238941d76d9a55bafb2481eda3fdf28f9
Contents?: true
Size: 1.05 KB
Versions: 5
Compression:
Stored size: 1.05 KB
Contents
require_relative 'base_matcher' module RSpec module GraphqlMatchers class AcceptArguments < BaseMatcher 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 '#{member_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 && types_match?(actual_arg.type, arg_type) end def describe_arguments(what_args) what_args.sort.map do |arg_name, arg_type| "#{arg_name}(#{arg_type})" end.join(', ') end end end end
Version data entries
5 entries across 5 versions & 1 rubygems