class ActiveRecordTest::MachineWithStateDrivenValidationsTest

Public Instance Methods

setup() click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1116
def setup
  @model = new_model do
    attr_accessor :seatbelt
  end
  
  @machine = StateMachine::Machine.new(@model)
  @machine.state :first_gear, :second_gear do
    validates_presence_of :seatbelt
  end
  @machine.other_states :parked
end
test_should_be_invalid_if_validation_fails_within_state_scope() click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1133
def test_should_be_invalid_if_validation_fails_within_state_scope
  record = @model.new(:state => 'first_gear', :seatbelt => nil)
  assert !record.valid?
end
test_should_be_valid_if_validation_fails_outside_state_scope() click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1128
def test_should_be_valid_if_validation_fails_outside_state_scope
  record = @model.new(:state => 'parked', :seatbelt => nil)
  assert record.valid?
end
test_should_be_valid_if_validation_succeeds_within_state_scope() click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1138
def test_should_be_valid_if_validation_succeeds_within_state_scope
  record = @model.new(:state => 'second_gear', :seatbelt => true)
  assert record.valid?
end