class DataMapperTest::MachineWithInitializedStateTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 457 def setup @resource = new_resource @machine = StateMachine::Machine.new(@resource, :initial => :parked) @machine.state :idling end
test_should_allow_different_initial_state_when_dynamic()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 483 def test_should_allow_different_initial_state_when_dynamic @machine.initial_state = lambda {:parked} record = @resource.new(:state => 'idling') assert_equal 'idling', record.state end
test_should_allow_different_initial_state_when_static()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 478 def test_should_allow_different_initial_state_when_static record = @resource.new(:state => 'idling') assert_equal 'idling', record.state end
test_should_allow_nil_initial_state_when_dynamic()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 470 def test_should_allow_nil_initial_state_when_dynamic @machine.state nil @machine.initial_state = lambda {:parked} record = @resource.new(:state => nil) assert_nil record.state end
test_should_allow_nil_initial_state_when_static()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 463 def test_should_allow_nil_initial_state_when_static @machine.state nil record = @resource.new(:state => nil) assert_nil record.state end
test_should_raise_exception_if_protected()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 490 def test_should_raise_exception_if_protected resource = new_resource do protected :state= end machine = StateMachine::Machine.new(resource, :initial => :parked) machine.state :idling assert_raise(ArgumentError) { resource.new(:state => 'idling') } end