class NodeCollectionWithIndicesTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/node_collection_test.rb, line 129 def setup machine = StateMachine::Machine.new(Class.new) @collection = StateMachine::NodeCollection.new(machine, :index => [:name, :value]) @object = Node.new(:parked, 1) @collection << @object end
test_should_allow_customizing_index_for_key_retrieval()
click to toggle source
# File test/unit/node_collection_test.rb, line 141 def test_should_allow_customizing_index_for_key_retrieval assert_equal [1], @collection.keys(:value) end
test_should_allow_customizing_index_on_fetch()
click to toggle source
# File test/unit/node_collection_test.rb, line 161 def test_should_allow_customizing_index_on_fetch assert_equal @object, @collection.fetch(1, :value) exception = assert_raise(IndexError) { @collection.fetch(:parked, :value) } assert_equal ':parked is an invalid value', exception.message end
test_should_allow_customizing_index_on_lookup()
click to toggle source
# File test/unit/node_collection_test.rb, line 150 def test_should_allow_customizing_index_on_lookup assert_equal @object, @collection[1, :value] assert_nil @collection[:parked, :value] end
test_should_use_first_index_by_default_on_fetch()
click to toggle source
# File test/unit/node_collection_test.rb, line 155 def test_should_use_first_index_by_default_on_fetch assert_equal @object, @collection.fetch(:parked) exception = assert_raise(IndexError) { @collection.fetch(1) } assert_equal '1 is an invalid name', exception.message end
test_should_use_first_index_by_default_on_key_retrieval()
click to toggle source
# File test/unit/node_collection_test.rb, line 137 def test_should_use_first_index_by_default_on_key_retrieval assert_equal [:parked], @collection.keys end
test_should_use_first_index_by_default_on_lookup()
click to toggle source
# File test/unit/node_collection_test.rb, line 145 def test_should_use_first_index_by_default_on_lookup assert_equal @object, @collection[:parked] assert_nil @collection[1] end