Parent

Class Index [+]

Quicksearch

Mocha::StateMachine

A state machine that is used to constrain the order of invocations. An invocation can be constrained to occur when a state {#}, or {#}, active.

Attributes

name[R]

@private

current_state[RW]

@private

Public Class Methods

new(name) click to toggle source

@private

    # File lib/mocha/state_machine.rb, line 59
59:     def initialize(name)
60:       @name = name
61:       @current_state = nil
62:     end

Public Instance Methods

become(next_state_name) click to toggle source

Put the {StateMachine} into the next_state_name.

@param [String] next_state_name name of new state

    # File lib/mocha/state_machine.rb, line 76
76:     def become(next_state_name)
77:       @current_state = next_state_name
78:     end
is(state_name) click to toggle source

Provides a mechanism to change the {StateMachine} into the state specified by state_name at some point in the future.

Or provides a mechanism to determine whether the {StateMachine} is in the state specified by state_name at some point in the future.

@param [String] state_name name of new state @return [State] state which, when activated, will change the {StateMachine} into the state with the specified state_name.

    # File lib/mocha/state_machine.rb, line 86
86:     def is(state_name)
87:       State.new(self, state_name)
88:     end
is_not(state_name) click to toggle source

Provides a mechanism to determine whether the {StateMachine} is not in the state specified by state_name at some point in the future.

    # File lib/mocha/state_machine.rb, line 91
91:     def is_not(state_name)
92:       StatePredicate.new(self, state_name)
93:     end
mocha_inspect() click to toggle source

@private

     # File lib/mocha/state_machine.rb, line 96
 96:     def mocha_inspect
 97:       if @current_state
 98:         "#{@name} is #{@current_state.mocha_inspect}"
 99:       else
100:         "#{@name} has no current state"
101:       end
102:     end
starts_as(initial_state_name) click to toggle source

Put the {StateMachine} into the state specified by initial_state_name.

@param [String] initial_state_name name of initial state @return [StateMachine] state machine, thereby allowing invocations of other {StateMachine} methods to be chained.

    # File lib/mocha/state_machine.rb, line 68
68:     def starts_as(initial_state_name)
69:       become(initial_state_name)
70:       self
71:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.