Class: ObjectProtocol::SatisfiableUnorderedMessageSequenceExpectation

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/object_protocol/satisfiable_unordered_message_sequence_expectation.rb

Instance Method Summary collapse

Constructor Details

#initialize(protocol:, sequence_expectation:) ⇒ SatisfiableUnorderedMessageSequenceExpectation

Returns a new instance of SatisfiableUnorderedMessageSequenceExpectation.



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

def initialize(protocol:, sequence_expectation:)
  @protocol             = protocol
  @sequence_expectation = sequence_expectation
end

Instance Method Details

#attempt_to_apply_sent_message(sent_message) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/object_protocol/satisfiable_unordered_message_sequence_expectation.rb', line 12

def attempt_to_apply_sent_message(sent_message)
  return if satisfied?

  satisfiable_expectations.each do |satisfiable_expectation|
    if satisfiable_expectation.unsatisfied?
      satisfiable_expectation.attempt_to_apply_sent_message(sent_message)

      break if satisfiable_expectation.satisfied?
    end
  end
end

#satisfied?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/object_protocol/satisfiable_unordered_message_sequence_expectation.rb', line 24

def satisfied?
  satisfiable_expectations.all?(&:satisfied?)
end