class TransitionAfterBeingPersistedTest

Public Instance Methods

setup() click to toggle source
# File test/unit/transition_test.rb, line 299
def setup
  @klass = Class.new
  @machine = StateMachine::Machine.new(@klass, :action => :save)
  @machine.state :parked, :idling
  @machine.event :ignite
  
  @object = @klass.new
  @object.state = 'parked'
  
  @transition = StateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling)
  @transition.persist
end
test_should_be_able_to_persist_again_after_resetting() click to toggle source
# File test/unit/transition_test.rb, line 330
def test_should_be_able_to_persist_again_after_resetting
  @object.state = 'parked'
  @transition.reset
  @transition.persist
  assert_equal 'idling', @object.state
end
test_should_not_be_able_to_persist_twice() click to toggle source
# File test/unit/transition_test.rb, line 324
def test_should_not_be_able_to_persist_twice
  @object.state = 'parked'
  @transition.persist
  assert_equal 'parked', @object.state
end
test_should_not_change_from_state() click to toggle source
# File test/unit/transition_test.rb, line 316
def test_should_not_change_from_state
  assert_equal 'parked', @transition.from
end
test_should_not_change_to_state() click to toggle source
# File test/unit/transition_test.rb, line 320
def test_should_not_change_to_state
  assert_equal 'idling', @transition.to
end
test_should_revert_to_from_state_on_rollback() click to toggle source
# File test/unit/transition_test.rb, line 337
def test_should_revert_to_from_state_on_rollback
  @transition.rollback
  assert_equal 'parked', @object.state
end
test_should_update_state_value() click to toggle source
# File test/unit/transition_test.rb, line 312
def test_should_update_state_value
  assert_equal 'idling', @object.state
end