class StateCollectionWithStateBehaviorsTest

Public Instance Methods

setup() click to toggle source
# File test/unit/state_collection_test.rb, line 203
def setup
  @machine = StateMachine::Machine.new(Class.new)
  @states = StateMachine::StateCollection.new(@machine)
  
  @states << @parked = StateMachine::State.new(@machine, :parked)
  @states << @idling = StateMachine::State.new(@machine, :idling)
  @machine.states.concat(@states)
  
  @idling.context do
    def speed
      0
    end
  end
end
speed() click to toggle source
# File test/unit/state_collection_test.rb, line 212
def speed
  0
end
test_should_order_state_before_callback_states() click to toggle source
# File test/unit/state_collection_test.rb, line 234
def test_should_order_state_before_callback_states
  @machine.before_transition :from => :parked, :do => lambda {}
  assert_equal [@idling, @parked], @states.by_priority
end
test_should_order_states_after_initial_state() click to toggle source
# File test/unit/state_collection_test.rb, line 218
def test_should_order_states_after_initial_state
  @parked.initial = true
  assert_equal [@parked, @idling], @states.by_priority
end
test_should_order_states_after_transition_states() click to toggle source
# File test/unit/state_collection_test.rb, line 223
def test_should_order_states_after_transition_states
  @machine.event :ignite do
    transition :from => :parked
  end
  assert_equal [@parked, @idling], @states.by_priority
end
test_should_order_states_before_other_states() click to toggle source
# File test/unit/state_collection_test.rb, line 230
def test_should_order_states_before_other_states
  assert_equal [@idling, @parked], @states.by_priority
end