class PathCollectionWithPathsTest

Public Instance Methods

setup() click to toggle source
# File test/unit/path_collection_test.rb, line 72
def setup
  @klass = Class.new
  @machine = StateMachine::Machine.new(@klass)
  @machine.state :parked, :idling, :first_gear
  @machine.event :ignite do
    transition :parked => :idling
  end
  @machine.event :shift_up do
    transition :idling => :first_gear
  end
  
  @object = @klass.new
  @object.state = 'parked'
  
  @paths = StateMachine::PathCollection.new(@object, @machine)
end
test_should_enumerate_paths() click to toggle source
# File test/unit/path_collection_test.rb, line 89
def test_should_enumerate_paths
  assert_equal [[
    StateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling),
    StateMachine::Transition.new(@object, @machine, :shift_up, :idling, :first_gear)
  ]], @paths
end
test_should_have_a_from_name() click to toggle source
# File test/unit/path_collection_test.rb, line 96
def test_should_have_a_from_name
  assert_equal :parked, @paths.from_name
end
test_should_have_from_states() click to toggle source
# File test/unit/path_collection_test.rb, line 104
def test_should_have_from_states
  assert_equal [:parked, :idling], @paths.from_states
end
test_should_have_no_events() click to toggle source
# File test/unit/path_collection_test.rb, line 112
def test_should_have_no_events
  assert_equal [:ignite, :shift_up], @paths.events
end
test_should_have_to_states() click to toggle source
# File test/unit/path_collection_test.rb, line 108
def test_should_have_to_states
  assert_equal [:idling, :first_gear], @paths.to_states
end
test_should_not_have_a_to_name() click to toggle source
# File test/unit/path_collection_test.rb, line 100
def test_should_not_have_a_to_name
  assert_nil @paths.to_name
end