class PathWithGuardedTransitionsTest

Public Instance Methods

setup() click to toggle source
# File test/unit/path_test.rb, line 227
def setup
  @klass = Class.new
  @machine = StateMachine::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
test_should_not_walk_transitions_if_guard_disabled() click to toggle source
# File test/unit/path_test.rb, line 252
def test_should_not_walk_transitions_if_guard_disabled
  path = StateMachine::Path.new(@object, @machine, :guard => false)
  path.concat([
    ignite_transition = StateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling)
  ])
  
  paths = []
  path.walk {|next_path| paths << next_path}
  
  assert_equal [
    [ignite_transition, StateMachine::Transition.new(@object, @machine, :shift_up, :idling, :first_gear)]
  ], paths
end
test_should_not_walk_transitions_if_guard_enabled() click to toggle source
# File test/unit/path_test.rb, line 240
def test_should_not_walk_transitions_if_guard_enabled
  path = StateMachine::Path.new(@object, @machine)
  path.concat([
    ignite_transition = StateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling)
  ])
  
  paths = []
  path.walk {|next_path| paths << next_path}
  
  assert_equal [], paths
end