Sha256: c2e016e498aae3454b460aa671812614495ff0d16b04adefa39b4b13b703ce64

Contents?: true

Size: 1.5 KB

Versions: 14

Compression:

Stored size: 1.5 KB

Contents

require_relative '../../test_helper'

class PathWithDeepTargetReachedTest < 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: :first_gear
    end
    @machine.event :park do
      transition [:idling, :first_gear] => :parked
    end

    @object = @klass.new
    @object.state = 'parked'

    @path = StateMachines::Path.new(@object, @machine, target: :parked)
    @path.concat([
                     @ignite_transition = StateMachines::Transition.new(@object, @machine, :ignite, :parked, :idling),
                     @park_transition = StateMachines::Transition.new(@object, @machine, :park, :idling, :parked),
                     @shift_up_transition = StateMachines::Transition.new(@object, @machine, :shift_up, :parked, :first_gear),
                     @park_transition_2 = StateMachines::Transition.new(@object, @machine, :park, :first_gear, :parked)
                 ])
  end

  def test_should_be_complete
    assert_equal true, @path.complete?
  end

  def test_should_not_be_able_to_walk
    walked = false
    @path.walk { walked = true }
    assert_equal false, walked
  end

  def test_should_not_be_able_to_walk_with_available_transitions
    @machine.event :park do
      transition parked: same
    end

    walked = false
    @path.walk { walked = true }
    assert_equal false, walked
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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