class VehicleWithParallelEventsTest

Public Instance Methods

setup() click to toggle source
# File test/functional/state_machine_test.rb, line 758
def setup
  @vehicle = Vehicle.new
end
test_should_be_successful_if_all_events_transition() click to toggle source
# File test/functional/state_machine_test.rb, line 766
def test_should_be_successful_if_all_events_transition
  assert @vehicle.fire_events(:ignite, :buy_insurance)
end
test_should_fail_if_any_event_cannot_transition() click to toggle source
# File test/functional/state_machine_test.rb, line 762
def test_should_fail_if_any_event_cannot_transition
  assert !@vehicle.fire_events(:ignite, :cancel_insurance)
end
test_should_not_raise_exception_if_all_events_transition_on_bang() click to toggle source
# File test/functional/state_machine_test.rb, line 781
def test_should_not_raise_exception_if_all_events_transition_on_bang
  assert @vehicle.fire_events!(:ignite, :buy_insurance)
end
test_should_not_save_if_skipping_action() click to toggle source
# File test/functional/state_machine_test.rb, line 770
def test_should_not_save_if_skipping_action
  assert @vehicle.fire_events(:ignite, :buy_insurance, false)
  assert !@vehicle.saved
end
test_should_not_save_if_skipping_action_on_bang() click to toggle source
# File test/functional/state_machine_test.rb, line 785
def test_should_not_save_if_skipping_action_on_bang
  assert @vehicle.fire_events!(:ignite, :buy_insurance, false)
  assert !@vehicle.saved
end
test_should_raise_exception_if_any_event_cannot_transition_on_bang() click to toggle source
# File test/functional/state_machine_test.rb, line 775
def test_should_raise_exception_if_any_event_cannot_transition_on_bang
  exception = assert_raise(StateMachine::InvalidParallelTransition) { @vehicle.fire_events!(:ignite, :cancel_insurance) }
  assert_equal @vehicle, exception.object
  assert_equal [:ignite, :cancel_insurance], exception.events
end