class MongoMapperTest::MachineWithInitializedStateTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/mongo_mapper_test.rb, line 457 def setup @model = new_model @machine = StateMachine::Machine.new(@model, :initial => :parked) @machine.state :idling end
test_should_allow_different_initial_state_when_dynamic()
click to toggle source
# File test/unit/integrations/mongo_mapper_test.rb, line 483 def test_should_allow_different_initial_state_when_dynamic @machine.initial_state = lambda {:parked} record = @model.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/mongo_mapper_test.rb, line 478 def test_should_allow_different_initial_state_when_static record = @model.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/mongo_mapper_test.rb, line 470 def test_should_allow_nil_initial_state_when_dynamic @machine.state nil @machine.initial_state = lambda {:parked} record = @model.new(:state => nil) assert_nil record.state end
test_should_allow_nil_initial_state_when_static()
click to toggle source
# File test/unit/integrations/mongo_mapper_test.rb, line 463 def test_should_allow_nil_initial_state_when_static @machine.state nil record = @model.new(:state => nil) assert_nil record.state end
test_should_use_default_state_if_protected()
click to toggle source
# File test/unit/integrations/mongo_mapper_test.rb, line 490 def test_should_use_default_state_if_protected @model.class_eval do attr_protected :state end record = @model.new(:state => 'idling') assert_equal 'parked', record.state end