class VehicleUnsavedTest
Public Instance Methods
setup()
click to toggle source
# File test/functional/state_machine_test.rb, line 262 def setup @vehicle = Vehicle.new end
test_should_allow_buying_insurance()
click to toggle source
# File test/functional/state_machine_test.rb, line 395 def test_should_allow_buying_insurance assert @vehicle.buy_insurance end
test_should_allow_buying_insurance_bang()
click to toggle source
# File test/functional/state_machine_test.rb, line 399 def test_should_allow_buying_insurance_bang assert @vehicle.buy_insurance! end
test_should_allow_ignite()
click to toggle source
# File test/functional/state_machine_test.rb, line 343 def test_should_allow_ignite assert @vehicle.ignite assert_equal 'idling', @vehicle.state end
test_should_allow_ignite_bang()
click to toggle source
# File test/functional/state_machine_test.rb, line 353 def test_should_allow_ignite_bang assert @vehicle.ignite! end
test_should_allow_ignite_bang_with_skipped_action()
click to toggle source
# File test/functional/state_machine_test.rb, line 357 def test_should_allow_ignite_bang_with_skipped_action assert @vehicle.ignite!(false) assert @vehicle.new_record? end
test_should_allow_ignite_buying_insurance_with_skipped_action()
click to toggle source
# File test/functional/state_machine_test.rb, line 403 def test_should_allow_ignite_buying_insurance_with_skipped_action assert @vehicle.buy_insurance!(false) assert @vehicle.new_record? end
test_should_allow_ignite_with_skipped_action()
click to toggle source
# File test/functional/state_machine_test.rb, line 348 def test_should_allow_ignite_with_skipped_action assert @vehicle.ignite(false) assert @vehicle.new_record? end
test_should_be_able_to_buy()
click to toggle source
# File test/functional/state_machine_test.rb, line 391 def test_should_be_able_to_buy assert @vehicle.can_buy_insurance? end
test_should_be_able_to_ignite()
click to toggle source
# File test/functional/state_machine_test.rb, line 314 def test_should_be_able_to_ignite assert @vehicle.can_ignite? end
test_should_be_in_parked_state()
click to toggle source
# File test/functional/state_machine_test.rb, line 266 def test_should_be_in_parked_state assert_equal 'parked', @vehicle.state end
test_should_be_insurance_inactive()
click to toggle source
# File test/functional/state_machine_test.rb, line 387 def test_should_be_insurance_inactive assert @vehicle.insurance_inactive? end
test_should_be_parked()
click to toggle source
# File test/functional/state_machine_test.rb, line 279 def test_should_be_parked assert @vehicle.parked? assert @vehicle.state?(:parked) assert_equal :parked, @vehicle.state_name assert_equal 'parked', @vehicle.human_state_name end
test_should_be_saved_after_successful_event()
click to toggle source
# File test/functional/state_machine_test.rb, line 362 def test_should_be_saved_after_successful_event @vehicle.ignite assert !@vehicle.new_record? end
test_should_have_a_list_of_possible_events()
click to toggle source
# File test/functional/state_machine_test.rb, line 328 def test_should_have_a_list_of_possible_events assert_equal [:ignite], @vehicle.state_events end
test_should_have_a_list_of_possible_paths()
click to toggle source
# File test/functional/state_machine_test.rb, line 336 def test_should_have_a_list_of_possible_paths assert_equal [[ StateMachine::Transition.new(@vehicle, Vehicle.state_machine, :ignite, :parked, :idling), StateMachine::Transition.new(@vehicle, Vehicle.state_machine, :shift_up, :idling, :first_gear) ]], @vehicle.state_paths(:to => :first_gear) end
test_should_have_a_list_of_possible_transitions()
click to toggle source
# File test/functional/state_machine_test.rb, line 332 def test_should_have_a_list_of_possible_transitions assert_equal [{:object => @vehicle, :attribute => :state, :event => :ignite, :from => 'parked', :to => 'idling'}], @vehicle.state_transitions.map {|transition| transition.attributes} end
test_should_have_a_transition_for_ignite()
click to toggle source
# File test/functional/state_machine_test.rb, line 318 def test_should_have_a_transition_for_ignite transition = @vehicle.ignite_transition assert_not_nil transition assert_equal 'parked', transition.from assert_equal 'idling', transition.to assert_equal :ignite, transition.event assert_equal :state, transition.attribute assert_equal @vehicle, transition.object end
test_should_not_allow_cancelling_insurance()
click to toggle source
# File test/functional/state_machine_test.rb, line 416 def test_should_not_allow_cancelling_insurance assert !@vehicle.cancel_insurance end
test_should_not_allow_crash()
click to toggle source
# File test/functional/state_machine_test.rb, line 379 def test_should_not_allow_crash assert !@vehicle.crash end
test_should_not_allow_idle()
click to toggle source
# File test/functional/state_machine_test.rb, line 367 def test_should_not_allow_idle assert !@vehicle.idle end
test_should_not_allow_park()
click to toggle source
# File test/functional/state_machine_test.rb, line 310 def test_should_not_allow_park assert !@vehicle.park end
test_should_not_allow_repair()
click to toggle source
# File test/functional/state_machine_test.rb, line 383 def test_should_not_allow_repair assert !@vehicle.repair end
test_should_not_allow_shift_down()
click to toggle source
# File test/functional/state_machine_test.rb, line 375 def test_should_not_allow_shift_down assert !@vehicle.shift_down end
test_should_not_allow_shift_up()
click to toggle source
# File test/functional/state_machine_test.rb, line 371 def test_should_not_allow_shift_up assert !@vehicle.shift_up end
test_should_not_be_able_to_cancel()
click to toggle source
# File test/functional/state_machine_test.rb, line 412 def test_should_not_be_able_to_cancel assert !@vehicle.can_cancel_insurance? end
test_should_not_be_able_to_park()
click to toggle source
# File test/functional/state_machine_test.rb, line 302 def test_should_not_be_able_to_park assert !@vehicle.can_park? end
test_should_not_be_first_gear()
click to toggle source
# File test/functional/state_machine_test.rb, line 290 def test_should_not_be_first_gear assert !@vehicle.first_gear? end
test_should_not_be_idling()
click to toggle source
# File test/functional/state_machine_test.rb, line 286 def test_should_not_be_idling assert !@vehicle.idling? end
test_should_not_be_insurance_active()
click to toggle source
# File test/functional/state_machine_test.rb, line 408 def test_should_not_be_insurance_active assert !@vehicle.insurance_active? end
test_should_not_be_second_gear()
click to toggle source
# File test/functional/state_machine_test.rb, line 294 def test_should_not_be_second_gear assert !@vehicle.second_gear? end
test_should_not_be_stalled()
click to toggle source
# File test/functional/state_machine_test.rb, line 298 def test_should_not_be_stalled assert !@vehicle.stalled? end
test_should_not_have_a_transition_for_park()
click to toggle source
# File test/functional/state_machine_test.rb, line 306 def test_should_not_have_a_transition_for_park assert_nil @vehicle.park_transition end
test_should_raise_exception_if_checking_invalid_state()
click to toggle source
# File test/functional/state_machine_test.rb, line 270 def test_should_raise_exception_if_checking_invalid_state assert_raise(IndexError) { @vehicle.state?(:invalid) } end
test_should_raise_exception_if_getting_name_of_invalid_state()
click to toggle source
# File test/functional/state_machine_test.rb, line 274 def test_should_raise_exception_if_getting_name_of_invalid_state @vehicle.state = 'invalid' assert_raise(ArgumentError) { @vehicle.state_name } end