Class: RSpec::GraphqlMatchers::AcceptArguments

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/graphql_matchers/accept_arguments.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_args) ⇒ AcceptArguments

Returns a new instance of AcceptArguments.



6
7
8
# File 'lib/rspec/graphql_matchers/accept_arguments.rb', line 6

def initialize(expected_args)
  @expected_args = expected_args
end

Instance Attribute Details

#actual_fieldObject (readonly)

Returns the value of attribute actual_field.



4
5
6
# File 'lib/rspec/graphql_matchers/accept_arguments.rb', line 4

def actual_field
  @actual_field
end

#expected_argsObject (readonly)

Returns the value of attribute expected_args.



4
5
6
# File 'lib/rspec/graphql_matchers/accept_arguments.rb', line 4

def expected_args
  @expected_args
end

Instance Method Details

#descriptionObject



23
24
25
# File 'lib/rspec/graphql_matchers/accept_arguments.rb', line 23

def description
  "accept arguments #{describe_arguments(expected_args)}"
end

#failure_messageObject



18
19
20
21
# File 'lib/rspec/graphql_matchers/accept_arguments.rb', line 18

def failure_message
  "expected field '#{field_name(actual_field)}' to accept arguments "\
  "#{describe_arguments(expected_args)}"
end

#matches?(actual_field) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
# File 'lib/rspec/graphql_matchers/accept_arguments.rb', line 10

def matches?(actual_field)
  @actual_field = actual_field

  @expected_args.all? do |arg_name, arg_type|
    matches_argument?(arg_name, arg_type)
  end
end