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.



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

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

Instance Method Details

#descriptionObject



28
29
30
# File 'lib/rspec/graphql_matchers/implement.rb', line 28

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

#failure_messageObject



16
17
18
19
20
# File 'lib/rspec/graphql_matchers/implement.rb', line 16

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

#failure_message_when_negatedObject



22
23
24
25
26
# File 'lib/rspec/graphql_matchers/implement.rb', line 22

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

#matches?(graph_object) ⇒ Boolean

Returns:

  • (Boolean)


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

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