Class: Mocha::Sequence

Inherits:
Object show all
Defined in:
lib/mocha/sequence.rb

Defined Under Namespace

Classes: InSequenceOrderingConstraint

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Sequence

Returns a new instance of Sequence.



21
22
23
24
# File 'lib/mocha/sequence.rb', line 21

def initialize(name)
  @name = name
  @expectations = []
end

Instance Method Details

#constrain_as_next_in_sequence(expectation) ⇒ Object



26
27
28
29
30
# File 'lib/mocha/sequence.rb', line 26

def constrain_as_next_in_sequence(expectation)
  index = @expectations.length
  @expectations << expectation
  expectation.add_ordering_constraint(InSequenceOrderingConstraint.new(self, index))
end

#mocha_inspectObject



36
37
38
# File 'lib/mocha/sequence.rb', line 36

def mocha_inspect
  "#{@name.mocha_inspect}"
end

#satisfied_to_index?(index) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/mocha/sequence.rb', line 32

def satisfied_to_index?(index)
  @expectations[0...index].all? { |expectation| expectation.satisfied? }
end