class NodeCollectionAfterBeingCopiedTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/node_collection_test.rb, line 56 def setup machine = StateMachine::Machine.new(Class.new) @collection = StateMachine::NodeCollection.new(machine) @collection << @parked = Node.new(:parked) @contexts_run = contexts_run = [] @collection.context([:parked]) {contexts_run << :parked} @contexts_run.clear @copied_collection = @collection.dup @copied_collection << @idling = Node.new(:idling) @copied_collection.context([:first_gear]) {contexts_run << :first_gear} end
test_should_copy_contexts()
click to toggle source
# File test/unit/node_collection_test.rb, line 93 def test_should_copy_contexts @copied_collection << Node.new(:parked) assert !@contexts_run.empty? end
test_should_copy_each_node()
click to toggle source
# File test/unit/node_collection_test.rb, line 80 def test_should_copy_each_node assert_not_same @parked, @copied_collection[:parked] end
test_should_not_modify_contexts()
click to toggle source
# File test/unit/node_collection_test.rb, line 88 def test_should_not_modify_contexts @collection << Node.new(:first_gear) assert_equal [], @contexts_run end
test_should_not_modify_the_indices()
click to toggle source
# File test/unit/node_collection_test.rb, line 75 def test_should_not_modify_the_indices assert_nil @collection[:idling] assert_equal @idling, @copied_collection[:idling] end
test_should_not_modify_the_original_list()
click to toggle source
# File test/unit/node_collection_test.rb, line 70 def test_should_not_modify_the_original_list assert_equal 1, @collection.length assert_equal 2, @copied_collection.length end
test_should_not_run_contexts()
click to toggle source
# File test/unit/node_collection_test.rb, line 84 def test_should_not_run_contexts assert_equal [], @contexts_run end