class StateCollectionWithEventTransitionsTest

Public Instance Methods

setup() click to toggle source
# File test/unit/state_collection_test.rb, line 241
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)
  
  @machine.event :ignite do
    transition :to => :idling
  end
end
speed() click to toggle source
# File test/unit/state_collection_test.rb, line 261
def speed
  0
end
test_should_order_state_before_callback_states() click to toggle source
# File test/unit/state_collection_test.rb, line 272
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 254
def test_should_order_states_after_initial_state
  @parked.initial = true
  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 268
def test_should_order_states_before_other_states
  assert_equal [@idling, @parked], @states.by_priority
end
test_should_order_states_before_states_with_behaviors() click to toggle source
# File test/unit/state_collection_test.rb, line 259
def test_should_order_states_before_states_with_behaviors
  @parked.context do
    def speed
      0
    end
  end
  assert_equal [@idling, @parked], @states.by_priority
end