Sha256: 109b3e02c2a421e66c2cfba2d287566f9fcf9e2ec8c40e169dbe775a871e2b56

Contents?: true

Size: 1.24 KB

Versions: 14

Compression:

Stored size: 1.24 KB

Contents

require_relative '../../test_helper'

class PathWithGuardedTransitionsTest < StateMachinesTest
  def setup
    @klass = Class.new
    @machine = StateMachines::Machine.new(@klass)
    @machine.state :parked, :idling
    @machine.event :ignite
    @machine.event :shift_up do
      transition idling: :first_gear, if: lambda { false }
    end

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

  def test_should_not_walk_transitions_if_guard_enabled
    path = StateMachines::Path.new(@object, @machine)
    path.concat([
                    StateMachines::Transition.new(@object, @machine, :ignite, :parked, :idling)
                ])

    paths = []
    path.walk { |next_path| paths << next_path }

    assert_equal [], paths
  end

  def test_should_not_walk_transitions_if_guard_disabled
    path = StateMachines::Path.new(@object, @machine, guard: false)
    path.concat([
                    ignite_transition = StateMachines::Transition.new(@object, @machine, :ignite, :parked, :idling)
                ])

    paths = []
    path.walk { |next_path| paths << next_path }

    assert_equal [
                     [ignite_transition, StateMachines::Transition.new(@object, @machine, :shift_up, :idling, :first_gear)]
                 ], paths
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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