Sha256: f9c8fdd226cf03e4912902d96122386cdb314f18aaa9f123e5b94c607789e0e6

Contents?: true

Size: 1.08 KB

Versions: 14

Compression:

Stored size: 1.08 KB

Contents

require_relative '../../test_helper'

class StateCollectionWithStateBehaviorsTest < StateMachinesTest
  def setup
    @machine = StateMachines::Machine.new(Class.new)
    @states = StateMachines::StateCollection.new(@machine)

    @states << @parked = StateMachines::State.new(@machine, :parked)
    @states << @idling = StateMachines::State.new(@machine, :idling)
    @machine.states.concat(@states)

    @idling.context do
      def speed
        0
      end
    end
  end

  def test_should_order_states_after_initial_state
    @parked.initial = true
    assert_equal [@parked, @idling], @states.by_priority
  end

  def test_should_order_states_after_transition_states
    @machine.event :ignite do
      transition from: :parked
    end
    assert_equal [@parked, @idling], @states.by_priority
  end

  def test_should_order_states_before_other_states
    assert_equal [@idling, @parked], @states.by_priority
  end

  def test_should_order_state_before_callback_states
    @machine.before_transition from: :parked, do: lambda {}
    assert_equal [@idling, @parked], @states.by_priority
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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