class DataMapperTest::MachineWithEventAttributesOnSaveBangTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1371 def setup @resource = new_resource @machine = StateMachine::Machine.new(@resource) @machine.event :ignite do transition :parked => :idling end @record = @resource.new @record.state = 'parked' @record.state_event = 'ignite' end
test_should_be_successful_if_event_has_transition()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1393 def test_should_be_successful_if_event_has_transition assert_equal true, @record.save! end
test_should_fail_if_event_has_no_transition()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1388 def test_should_fail_if_event_has_no_transition @record.state = 'idling' assert !@record.save! end
test_should_fail_if_event_is_invalid()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1383 def test_should_fail_if_event_is_invalid @record.state_event = 'invalid' assert !@record.save! end
test_should_persist_new_state()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1429 def test_should_persist_new_state @record.save! assert_equal 'idling', @record.state end
test_should_run_after_callbacks()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1434 def test_should_run_after_callbacks ran_callback = false @machine.after_transition { ran_callback = true } @record.save! assert ran_callback end
test_should_run_around_callbacks_after_yield()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1442 def test_should_run_around_callbacks_after_yield ran_callback = [false] @machine.around_transition {|block| block.call; ran_callback[0] = true } @record.save! assert ran_callback[0] end
test_should_run_around_callbacks_before_yield()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1413 def test_should_run_around_callbacks_before_yield ran_callback = false @machine.around_transition {|block| ran_callback = true; block.call } @record.save! assert ran_callback end
test_should_run_around_callbacks_before_yield_once()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1421 def test_should_run_around_callbacks_before_yield_once around_before_count = 0 @machine.around_transition {|block| around_before_count += 1; block.call } @record.save! assert_equal 1, around_before_count end
test_should_run_before_callbacks()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1397 def test_should_run_before_callbacks ran_callback = false @machine.before_transition { ran_callback = true } @record.save! assert ran_callback end
test_should_run_before_callbacks_once()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1405 def test_should_run_before_callbacks_once before_count = 0 @machine.before_transition { before_count += 1 } @record.save! assert_equal 1, before_count end