Sha256: 1406eb66fa4596e7b8d98e5edefff90b1b464cca2e7a7ab6bb3c2f8ba5d0e826
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
require_relative 'test_helper' class MachineWithFailedActionTest < BaseTestCase def setup @model = new_model do validates_numericality_of :state end @machine = StateMachines::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 = StateMachines::Transition.new(@record, @machine, :ignite, :parked, :idling) @result = @transition.perform end def test_should_not_be_successful assert !@result end def test_should_not_change_current_state assert_equal 'parked', @record.state end def test_should_not_save_record assert @record.new_record? end def test_should_run_before_callbacks_and_after_callbacks_with_failures assert_equal [:before, :around_before, :after_failure], @callbacks end end
Version data entries
3 entries across 3 versions & 1 rubygems