class DataMapperTest::MachineWithColumnStateAttributeTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 357 def setup @resource = new_resource @machine = StateMachine::Machine.new(@resource, :initial => :parked) @machine.other_states(:idling) @record = @resource.new end
test_should_have_an_attribute_predicate()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 375 def test_should_have_an_attribute_predicate assert @record.respond_to?(:state?) end
test_should_not_override_the_column_reader()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 365 def test_should_not_override_the_column_reader @record.attribute_set(:state, 'parked') assert_equal 'parked', @record.state end
test_should_not_override_the_column_writer()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 370 def test_should_not_override_the_column_writer @record.state = 'parked' assert_equal 'parked', @record.attribute_get(:state) end
test_should_raise_exception_for_predicate_if_invalid_state_specified()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 392 def test_should_raise_exception_for_predicate_if_invalid_state_specified assert_raise(IndexError) { @record.state?(:invalid) } end
test_should_raise_exception_for_predicate_without_parameters()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 379 def test_should_raise_exception_for_predicate_without_parameters exception = assert_raise(ArgumentError) { @record.state? } assert_equal 'wrong number of arguments (1 for 2)', exception.message end
test_should_return_false_for_predicate_if_does_not_match_current_value()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 384 def test_should_return_false_for_predicate_if_does_not_match_current_value assert !@record.state?(:idling) end
test_should_return_true_for_predicate_if_matches_current_value()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 388 def test_should_return_true_for_predicate_if_matches_current_value assert @record.state?(:parked) end