Sha256: c272f2e43344a15e28e940cb5c94075fdddc5900192be9510df4d46e3a23b89f

Contents?: true

Size: 1.47 KB

Versions: 14

Compression:

Stored size: 1.47 KB

Contents

require_relative '../../test_helper'

class PathCollectionWithDeepPathsTest < StateMachinesTest
  def setup
    @klass = Class.new
    @machine = StateMachines::Machine.new(@klass)
    @machine.state :parked, :idling
    @machine.event :ignite do
      transition parked: :idling
    end
    @machine.event :shift_up do
      transition parked: :idling, idling: :first_gear
    end
    @machine.event :shift_down do
      transition first_gear: :idling
    end
    @object = @klass.new
    @object.state = 'parked'

    @paths = StateMachines::PathCollection.new(@object, @machine, to: :idling, deep: true)
  end

  def test_should_allow_target_to_be_reached_more_than_once_per_path
    assert_equal [
      [
        StateMachines::Transition.new(@object, @machine, :ignite, :parked, :idling)
      ],
      [
        StateMachines::Transition.new(@object, @machine, :ignite, :parked, :idling),
        StateMachines::Transition.new(@object, @machine, :shift_up, :idling, :first_gear),
        StateMachines::Transition.new(@object, @machine, :shift_down, :first_gear, :idling)
      ],
      [
        StateMachines::Transition.new(@object, @machine, :shift_up, :parked, :idling)
      ],
      [
        StateMachines::Transition.new(@object, @machine, :shift_up, :parked, :idling),
        StateMachines::Transition.new(@object, @machine, :shift_up, :idling, :first_gear),
        StateMachines::Transition.new(@object, @machine, :shift_down, :first_gear, :idling)
      ]
    ], @paths
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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