class PathWithDeepTargetReachedTest

Public Instance Methods

setup() click to toggle source
# File test/unit/path_test.rb, line 440
def setup
  @klass = Class.new
  @machine = StateMachine::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 = StateMachine::Path.new(@object, @machine, :target => :parked)
  @path.concat([
    @ignite_transition = StateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling),
    @park_transition = StateMachine::Transition.new(@object, @machine, :park, :idling, :parked),
    @shift_up_transition = StateMachine::Transition.new(@object, @machine, :shift_up, :parked, :first_gear),
    @park_transition_2 = StateMachine::Transition.new(@object, @machine, :park, :first_gear, :parked)
  ])
end
test_should_be_complete() click to toggle source
# File test/unit/path_test.rb, line 466
def test_should_be_complete
  assert_equal true, @path.complete?
end
test_should_not_be_able_to_walk() click to toggle source
# File test/unit/path_test.rb, line 470
def test_should_not_be_able_to_walk
  walked = false
  @path.walk { walked = true }
  assert_equal false, walked
end
test_should_not_be_able_to_walk_with_available_transitions() click to toggle source
# File test/unit/path_test.rb, line 476
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