class ActiveRecordTest::MachineWithColumnStateAttributeTest

Public Instance Methods

setup() click to toggle source
# File test/unit/integrations/active_record_test.rb, line 385
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/active_record_test.rb, line 403
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/active_record_test.rb, line 393
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/active_record_test.rb, line 398
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/active_record_test.rb, line 422
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/active_record_test.rb, line 414
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/active_record_test.rb, line 418
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/active_record_test.rb, line 407
def test_should_test_for_existence_on_predicate_without_parameters
  assert @record.state?
  
  @record.state = nil
  assert !@record.state?
end