Sha256: a612ef911a7b302d755307203cb0994a1399c7ee014bdd789f3c949757606ab4

Contents?: true

Size: 923 Bytes

Versions: 14

Compression:

Stored size: 923 Bytes

Contents

require_relative '../../test_helper'

class TransitionCollectionWithSkippedAfterCallbacksTest < StateMachinesTest
  def setup
    @klass = Class.new

    @callbacks = []

    @machine = StateMachines::Machine.new(@klass, initial: :parked)
    @machine.state :idling
    @machine.event :ignite
    @machine.after_transition { @callbacks << :after }

    @object = @klass.new

    @transitions = StateMachines::TransitionCollection.new([
      @transition = StateMachines::Transition.new(@object, @machine, :ignite, :parked, :idling)
    ], after: false)
    @result = @transitions.perform
  end

  def test_should_succeed
    assert_equal true, @result
  end

  def test_should_not_run_after_callbacks
    refute @callbacks.include?(:after)
  end

  def test_should_run_after_callbacks_on_subsequent_perform
    StateMachines::TransitionCollection.new([@transition]).perform
    assert @callbacks.include?(:after)
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
state_machines-0.5.0 test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-0.2.2/test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-0.2.2/test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-0.2.2/test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
state_machines-0.4.0 test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
state_machines-0.3.0 test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
state_machines-0.2.2 test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
state_machines-0.2.1 test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
state_machines-0.2.0 test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
state_machines-0.1.4 test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
state_machines-0.1.3 test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
state_machines-0.1.2 test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
state_machines-0.1.1 test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb
state_machines-0.1.0 test/unit/transition_collection/transition_collection_with_skipped_after_callbacks_test.rb