Class: Mocha::Sequence
Overview
Used to constrain the order in which expectations can occur.
Defined Under Namespace
Classes: InSequenceOrderingConstraint
Instance Method Summary collapse
- #constrain_as_next_in_sequence(expectation) ⇒ Object
-
#initialize(name) ⇒ Sequence
constructor
A new instance of Sequence.
- #mocha_inspect ⇒ Object
- #satisfied_to_index?(index) ⇒ Boolean
Constructor Details
#initialize(name) ⇒ Sequence
Returns a new instance of Sequence.
27 28 29 30 |
# File 'lib/mocha/sequence.rb', line 27 def initialize(name) @name = name @expectations = [] end |
Instance Method Details
#constrain_as_next_in_sequence(expectation) ⇒ Object
33 34 35 36 37 |
# File 'lib/mocha/sequence.rb', line 33 def constrain_as_next_in_sequence(expectation) index = @expectations.length @expectations << expectation expectation.add_ordering_constraint(InSequenceOrderingConstraint.new(self, index)) end |
#mocha_inspect ⇒ Object
45 46 47 |
# File 'lib/mocha/sequence.rb', line 45 def mocha_inspect "#{@name.mocha_inspect}" end |
#satisfied_to_index?(index) ⇒ Boolean
40 41 42 |
# File 'lib/mocha/sequence.rb', line 40 def satisfied_to_index?(index) @expectations[0...index].all? { |expectation| expectation.satisfied? } end |