class PathWithTransitionsTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/path_test.rb, line 91 def setup @klass = Class.new @machine = StateMachine::Machine.new(@klass) @machine.state :parked, :idling, :first_gear @machine.event :ignite, :shift_up @object = @klass.new @object.state = 'parked' @path = StateMachine::Path.new(@object, @machine) @path.concat([ @ignite_transition = StateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling), @shift_up_transition = StateMachine::Transition.new(@object, @machine, :shift_up, :idling, :first_gear) ]) end
test_should_be_complete()
click to toggle source
# File test/unit/path_test.rb, line 137 def test_should_be_complete assert_equal true, @path.complete? end
test_should_enumerate_transitions()
click to toggle source
# File test/unit/path_test.rb, line 107 def test_should_enumerate_transitions assert_equal [@ignite_transition, @shift_up_transition], @path end
test_should_have_a_from_name()
click to toggle source
# File test/unit/path_test.rb, line 111 def test_should_have_a_from_name assert_equal :parked, @path.from_name end
test_should_have_a_to_name()
click to toggle source
# File test/unit/path_test.rb, line 119 def test_should_have_a_to_name assert_equal :first_gear, @path.to_name end
test_should_have_events()
click to toggle source
# File test/unit/path_test.rb, line 127 def test_should_have_events assert_equal [:ignite, :shift_up], @path.events end
test_should_have_from_states()
click to toggle source
# File test/unit/path_test.rb, line 115 def test_should_have_from_states assert_equal [:parked, :idling], @path.from_states end
test_should_have_to_states()
click to toggle source
# File test/unit/path_test.rb, line 123 def test_should_have_to_states assert_equal [:idling, :first_gear], @path.to_states end
test_should_not_be_able_to_walk_anywhere()
click to toggle source
# File test/unit/path_test.rb, line 131 def test_should_not_be_able_to_walk_anywhere walked = false @path.walk { walked = true } assert_equal false, walked end