Class: Mocha::StateMachine

### Home Classes Methods

### In Files

- lib/mocha/state_machine.rb

### Parent

Object

### Methods

- #become
- #is
- #is_not
- #starts_as

### Files

- COPYING
- README

### Class/Module Index

Quicksearch

- Mocha
- Mocha::API
- Mocha::AnyInstanceMethod
- Mocha::ArgumentIterator
- Mocha::ArrayMethods
- Mocha::BacktraceFilter
- Mocha::Cardinality
- Mocha::Central
- Mocha::ChangeStateSideEffect
- Mocha::ClassMethod
- Mocha::ClassMethods
- Mocha::Configuration
- Mocha::DateMethods
- Mocha::DefaultName
- Mocha::Deprecation
- Mocha::Expectation
- Mocha::ExpectationError
- Mocha::ExpectationList
- Mocha::HashMethods
- Mocha::ImpersonatingAnyInstanceName
- Mocha::ImpersonatingName
- Mocha::InStateOrderingConstraint
- Mocha::InstanceMethod
- Mocha::Integration
- Mocha::Integration::MiniTest
- Mocha::Integration::MiniTest::AssertionCounter
- Mocha::Integration::MiniTest::Version131AndAbove
- Mocha::Integration::TestUnit
- Mocha::Integration::TestUnit::AssertionCounter
- Mocha::Integration::TestUnit::GemVersion200
- Mocha::Integration::TestUnit::GemVersion201AndAbove
- Mocha::Integration::TestUnit::RubyVersion185AndBelow
- Mocha::Integration::TestUnit::RubyVersion186AndAbove
- Mocha::Logger
- Mocha::MethodMatcher
- Mocha::Mock
- Mocha::Mockery
- Mocha::ModuleMethod
- Mocha::Name
- Mocha::ObjectMethods
- Mocha::ParameterMatchers
- Mocha::ParametersMatcher
- Mocha::PrettyParameters
- Mocha::Sequence
- Mocha::Sequence::InSequenceOrderingConstraint
- Mocha::StateMachine
- Mocha::StringMethods
- Mocha::StubbingError
- Mocha::TimeMethods
- Mocha::UnexpectedInvocation
- MiniTest
- MiniTest::Unit
- MiniTest::Unit::TestCase
- Test
- Test::Unit
- Test::Unit::TestCase
- Array
- Date
- Hash
- Object
- String
- Time

No matching classes.

# Mocha::StateMachine

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

### Public Instance Methods

become(next_state) click to toggle source

Put the `state_machine` into the `next_state`.

    # File lib/mocha/state_machine.rb, line 63
    def become(next_state)
      @current_state = next_state
    end

is(state) click to toggle source

Determines whether the `state_machine` is in the specified `state`.

    # File lib/mocha/state_machine.rb, line 70
    def is(state)
      State.new(self, state)
    end

is_not(state) click to toggle source

Determines whether the `state_machine` is not in the specified `state`.

    # File lib/mocha/state_machine.rb, line 77
    def is_not(state)
      StatePredicate.new(self, state)
    end

starts_as(initial_state) → state_machine click to toggle source

Put the `state_machine` into the `initial_state`.

    # File lib/mocha/state_machine.rb, line 55
    def starts_as(initial_state)
      become(initial_state)
      self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.