class SequelTest::MachineWithFailedActionTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/sequel_test.rb, line 855 def setup @model = new_model do plugin(:validation_class_methods) if respond_to?(:plugin) validates_each :state do |object, attribute, value| object.errors[attribute] << 'is invalid' unless %w(first_gear).include?(value) end end @machine = StateMachine::Machine.new(@model) @machine.state :parked, :idling @machine.event :ignite callbacks = [] @machine.before_transition {callbacks << :before} @machine.after_transition {callbacks << :after} @machine.after_failure {callbacks << :after_failure} @machine.around_transition {|block| callbacks << :around_before; block.call; callbacks << :around_after} @record = @model.new(:state => 'parked') @transition = StateMachine::Transition.new(@record, @machine, :ignite, :parked, :idling) @result = @transition.perform @callbacks = callbacks end
test_should_not_be_successful()
click to toggle source
# File test/unit/integrations/sequel_test.rb, line 880 def test_should_not_be_successful assert !@result end
test_should_not_change_current_state()
click to toggle source
# File test/unit/integrations/sequel_test.rb, line 884 def test_should_not_change_current_state assert_equal 'parked', @record.state end
test_should_not_save_record()
click to toggle source
# File test/unit/integrations/sequel_test.rb, line 888 def test_should_not_save_record assert @record.new? end
test_should_run_before_callbacks_and_after_callbacks_with_failures()
click to toggle source
# File test/unit/integrations/sequel_test.rb, line 892 def test_should_run_before_callbacks_and_after_callbacks_with_failures assert_equal [:before, :around_before, :after_failure], @callbacks end