class NodeCollectionWithNodesTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/node_collection_test.rb, line 169 def setup @machine = StateMachine::Machine.new(Class.new) @collection = StateMachine::NodeCollection.new(@machine) @parked = Node.new(:parked, nil, @machine) @idling = Node.new(:idling, nil, @machine) @collection << @parked @collection << @idling end
test_should_be_able_to_access_by_index()
click to toggle source
# File test/unit/node_collection_test.rb, line 197 def test_should_be_able_to_access_by_index assert_equal @parked, @collection.at(0) assert_equal @idling, @collection.at(1) end
test_should_be_able_to_concatenate_multiple_nodes()
click to toggle source
# File test/unit/node_collection_test.rb, line 187 def test_should_be_able_to_concatenate_multiple_nodes @first_gear = Node.new(:first_gear, nil, @machine) @second_gear = Node.new(:second_gear, nil, @machine) @collection.concat([@first_gear, @second_gear]) order = [] @collection.each {|object| order << object} assert_equal [@parked, @idling, @first_gear, @second_gear], order end
test_should_be_able_to_enumerate()
click to toggle source
# File test/unit/node_collection_test.rb, line 180 def test_should_be_able_to_enumerate order = [] @collection.each {|object| order << object} assert_equal [@parked, @idling], order end
test_should_deep_copy_machine_changes()
click to toggle source
# File test/unit/node_collection_test.rb, line 202 def test_should_deep_copy_machine_changes new_machine = StateMachine::Machine.new(Class.new) @collection.machine = new_machine assert_equal new_machine, @collection.machine assert_equal new_machine, @parked.machine assert_equal new_machine, @idling.machine end