class MongoidTest::MachineWithColumnStateAttributeTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 300 def setup @model = new_model @machine = StateMachine::Machine.new(@model, :initial => :parked) @machine.other_states(:idling) @record = @model.new end
test_should_have_an_attribute_predicate()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 318 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/mongoid_test.rb, line 308 def test_should_not_override_the_column_reader @record[:state] = 'parked' assert_equal 'parked', @record.state end
test_should_not_override_the_column_writer()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 313 def test_should_not_override_the_column_writer @record.state = 'parked' assert_equal 'parked', @record[:state] end
test_should_raise_exception_for_predicate_if_invalid_state_specified()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 337 def test_should_raise_exception_for_predicate_if_invalid_state_specified assert_raise(IndexError) { @record.state?(:invalid) } end
test_should_return_false_for_predicate_if_does_not_match_current_value()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 329 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/mongoid_test.rb, line 333 def test_should_return_true_for_predicate_if_matches_current_value assert @record.state?(:parked) end
test_should_test_for_existence_on_predicate_without_parameters()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 322 def test_should_test_for_existence_on_predicate_without_parameters assert @record.state? @record.state = nil assert !@record.state? end