Class: SatisfactionAttemptVerifier

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

Instance Method Summary collapse

Constructor Details

#initialize(&blk) ⇒ SatisfactionAttemptVerifier

Returns a new instance of SatisfactionAttemptVerifier.



7
8
9
# File 'lib/object_protocol/rspec.rb', line 7

def initialize(&blk)
  @blk = blk
end

Instance Method Details

#failure_messageObject



18
19
20
21
22
23
24
25
# File 'lib/object_protocol/rspec.rb', line 18

def failure_message
  [
    "expected",
    *protocol.to_rspec_matcher_failure_message_lines.flat_map(&"  ".method(:+)),
    "to be satisfied by",
    *attempt.to_rspec_matcher_failure_message_lines.flat_map(&"  ".method(:+)),
  ].join("\n")
end

#matches?(protocol) ⇒ Boolean

Returns:

  • (Boolean)


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

def matches?(protocol)
  @protocol = protocol
  @attempt  = ObjectProtocol::SatisfactionAttempt.new(protocol, &blk)

  attempt.to_bool
end