class MongoidTest::MachineWithInitializedStateTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 449 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/mongoid_test.rb, line 475 def test_should_allow_different_initial_state_when_dynamic @machine.initial_state = lambda {:parked} record = silence_warnings { @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/mongoid_test.rb, line 470 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/mongoid_test.rb, line 462 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/mongoid_test.rb, line 455 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/mongoid_test.rb, line 481 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