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