class Mocha::Expectation

def when(state_predicate)

Other tags:
    Example: Using {#when} to only allow invocation of methods when "power" state machine is in the "on" state. -

Other tags:
    See: #then -
    See: StateMachine -
    See: API#states -

Returns:
  • (Expectation) - the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.

Parameters:
  • state_predicate (StateMachine::StatePredicate) -- +state_machine.is(state_name)+ provides a mechanism to determine whether the +state_machine+ is in the state specified by +state_predicate+ when the expected method is invoked.
def when(state_predicate)
  add_ordering_constraint(InStateOrderingConstraint.new(state_predicate))
  self
end