Class: ObjectProtocol::SatisfactionAttempt
- Inherits:
-
Object
- Object
- ObjectProtocol::SatisfactionAttempt
- Defined in:
- lib/object_protocol/satisfaction_attempt.rb
Instance Method Summary collapse
-
#initialize(protocol, &blk) ⇒ SatisfactionAttempt
constructor
A new instance of SatisfactionAttempt.
- #to_bool ⇒ Object
- #to_rspec_matcher_failure_message_lines ⇒ Object
Constructor Details
#initialize(protocol, &blk) ⇒ SatisfactionAttempt
Returns a new instance of SatisfactionAttempt.
5 6 7 8 |
# File 'lib/object_protocol/satisfaction_attempt.rb', line 5 def initialize(protocol, &blk) @protocol = protocol @blk = blk end |
Instance Method Details
#to_bool ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/object_protocol/satisfaction_attempt.rb', line 10 def to_bool execution.call(protocol) satisfiable_expectations = protocol.expectations.map(&:to_satisfiable) execution..each do || next_expectation = satisfiable_expectations.first next_expectation.() if next_expectation.satisfied? satisfiable_expectations.shift end end satisfiable_expectations.empty? end |
#to_rspec_matcher_failure_message_lines ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/object_protocol/satisfaction_attempt.rb', line 28 def return ["<empty execution>"] if execution..empty? execution..map do || fragment_base = "#{protocol.name_of_participant(.sender)}"\ ".sent(:#{.name})"\ ".to(#{protocol.name_of_participant(.receiver)})" if .arguments_passed? "#{fragment_base}.with(#{.arguments})" else fragment_base end end end |