Sha256: cb6302cb650bc1fa3a48bd2117ea176f2a47f16f236cf462efc12fc9822ade23
Contents?: true
Size: 856 Bytes
Versions: 1
Compression:
Stored size: 856 Bytes
Contents
require_relative 'test_helper' class MachineWithStateDrivenValidationsTest < BaseTestCase def setup @model = new_model do attr_accessor :seatbelt end @machine = StateMachines::Machine.new(@model) @machine.state :first_gear, :second_gear do validates :seatbelt, presence: true end @machine.other_states :parked end def test_should_be_valid_if_validation_fails_outside_state_scope record = @model.new(:state => 'parked', :seatbelt => nil) assert record.valid? end def test_should_be_invalid_if_validation_fails_within_state_scope record = @model.new(:state => 'first_gear', :seatbelt => nil) refute record.valid? end def test_should_be_valid_if_validation_succeeds_within_state_scope record = @model.new(:state => 'second_gear', :seatbelt => true) assert record.valid? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
state_machines-activerecord-0.9.0 | test/machine_with_state_driven_validations_test.rb |