class DataMapperTest::MachineWithStaticInitialStateTest
Public Instance Methods
attributes=(attributes)
click to toggle source
Calls superclass method
# File test/unit/integrations/data_mapper_test.rb, line 160 def attributes=(attributes) super(attributes || {}) end
setup()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 146 def setup @resource = new_resource do attr_accessor :value end @machine = StateMachine::Machine.new(@resource, :initial => :parked) end
test_should_not_allow_initialize_blocks()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 174 def test_should_not_allow_initialize_blocks block_args = nil record = @resource.new do |*args| block_args = args end assert_nil block_args end
test_should_not_set_initial_state_after_already_initialized()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 196 def test_should_not_set_initial_state_after_already_initialized record = @resource.new(:value => 1) assert_equal 'parked', record.state record.state = 'idling' record.attributes = {} assert_equal 'idling', record.state end
test_should_set_initial_state_before_setting_attributes()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 183 def test_should_set_initial_state_before_setting_attributes @resource.class_eval do attr_accessor :state_during_setter define_method(:value=) do |value| self.state_during_setter = state end end record = @resource.new(:value => 1) assert_equal 'parked', record.state_during_setter end
test_should_set_initial_state_on_created_object()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 153 def test_should_set_initial_state_on_created_object record = @resource.new assert_equal 'parked', record.state end
test_should_set_initial_state_with_nil_attributes()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 158 def test_should_set_initial_state_with_nil_attributes @resource.class_eval do def attributes=(attributes) super(attributes || {}) end end record = @resource.new(nil) assert_equal 'parked', record.state end
test_should_still_set_attributes()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 169 def test_should_still_set_attributes record = @resource.new(:value => 1) assert_equal 1, record.value end
test_should_use_stored_values_when_loading_from_database()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 205 def test_should_use_stored_values_when_loading_from_database @machine.state :idling record = @resource.get(@resource.create(:state => 'idling').id) assert_equal 'idling', record.state end
test_should_use_stored_values_when_loading_from_database_with_nil_state()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 212 def test_should_use_stored_values_when_loading_from_database_with_nil_state @machine.state nil record = @resource.get(@resource.create(:state => nil).id) assert_nil record.state end