class AttributeTransitionCollectionWithEventsTest

Public Instance Methods

setup() click to toggle source
# File test/unit/transition_collection_test.rb, line 1521
def setup
  @klass = Class.new
  
  @state = StateMachine::Machine.new(@klass, :initial => :parked, :action => :save)
  @state.state :idling
  @state.event :ignite
  
  @status = StateMachine::Machine.new(@klass, :status, :initial => :first_gear, :action => :save)
  @status.state :second_gear
  @status.event :shift_up
  
  @object = @klass.new
  @object.state_event = 'ignite'
  @object.status_event = 'shift_up'
  
  @transitions = StateMachine::AttributeTransitionCollection.new([
    @state_transition = StateMachine::Transition.new(@object, @state, :ignite, :parked, :idling),
    @status_transition = StateMachine::Transition.new(@object, @status, :shift_up, :first_gear, :second_gear)
  ])
  @result = @transitions.perform
end
test_should_clear_events() click to toggle source
# File test/unit/transition_collection_test.rb, line 1552
def test_should_clear_events
  assert_nil @object.state_event
  assert_nil @object.status_event
end
test_should_not_write_event_transitions() click to toggle source
# File test/unit/transition_collection_test.rb, line 1557
def test_should_not_write_event_transitions
  assert_nil @object.send(:state_event_transition)
  assert_nil @object.send(:status_event_transition)
end
test_should_persist_states() click to toggle source
# File test/unit/transition_collection_test.rb, line 1547
def test_should_persist_states
  assert_equal 'idling', @object.state
  assert_equal 'second_gear', @object.status
end
test_should_succeed() click to toggle source
# File test/unit/transition_collection_test.rb, line 1543
def test_should_succeed
  assert_equal true, @result
end