Class: RSpec::GraphqlMatchers::Implement

Inherits:
BaseMatcher show all
Defined in:
lib/rspec/graphql_matchers/implement.rb

Instance Method Summary collapse

Constructor Details

#initialize(interfaces) ⇒ Implement

Returns a new instance of Implement.



8
9
10
# File 'lib/rspec/graphql_matchers/implement.rb', line 8

def initialize(interfaces)
  @expected = interfaces.map { |interface| interface_name(interface) }
end

Instance Method Details

#descriptionObject



30
31
32
# File 'lib/rspec/graphql_matchers/implement.rb', line 30

def description
  "implement #{@expected.join(', ')}"
end

#failure_messageObject



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

def failure_message
  message  = "expected interfaces: #{@expected.join(', ')}\n"
  message += "actual interfaces:   #{@actual.join(', ')}"
  message
end

#failure_message_when_negatedObject



24
25
26
27
28
# File 'lib/rspec/graphql_matchers/implement.rb', line 24

def failure_message_when_negated
  message  = "unexpected interfaces: #{@expected.join(', ')}\n"
  message += "actual interfaces:     #{@actual.join(', ')}"
  message
end

#matches?(graph_object) ⇒ Boolean

Returns:

  • (Boolean)


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

def matches?(graph_object)
  @graph_object = graph_object
  @actual = actual
  @expected.all? { |name| @actual.include?(name) }
end