class Mocha::StateMachine
An invocation can be constrained to occur when a state {#is}, or {#is_not}, active.
A state machine that is used to constrain the order of invocations.
def become(next_state_name)
-
next_state_name(String) -- name of new state
def become(next_state_name) @current_state = next_state_name end
def initialize(name)
- Private: -
def initialize(name) @name = name @current_state = nil end
def is(state_name)
-
(State)- state which, when activated, will change the {StateMachine} into the state with the specified +state_name+.
Parameters:
-
state_name(String) -- name of new state
def is(state_name) State.new(self, state_name) end
def is_not(state_name)
def is_not(state_name) StatePredicate.new(self, state_name) end
def mocha_inspect
- Private: -
def mocha_inspect if @current_state "#{@name} is #{@current_state.mocha_inspect}" else "#{@name} has no current state" end end
def starts_as(initial_state_name)
-
(StateMachine)- state machine, thereby allowing invocations of other {StateMachine} methods to be chained.
Parameters:
-
initial_state_name(String) -- name of initial state
def starts_as(initial_state_name) become(initial_state_name) self end