Permalink
Browse files

MQ::Collection#<< always returns the item even if it already existed …

…in the collection.
  • Loading branch information...
1 parent 7415747 commit f8085cde9e1b15c52115aeaa581d1994775113b9 Jakub Šťastný aka Botanicus committed Nov 18, 2010
Showing with 8 additions and 0 deletions.
  1. +8 −0 lib/mq/collection.rb
View
@@ -28,6 +28,8 @@ def <<(item)
if (item.name rescue nil).nil? || ! self[item.name]
self.add!(item)
end
+
+ return item
end
alias_method :__push__, :push
@@ -95,6 +97,12 @@ def add!(item)
item = Item.new("test")
(@collection << item).should.eql item
end
+
+ should "return the item even if it already existed" do
+ item = Item.new("test")
+ @collection << item
+ (@collection << item).should.eql item
+ end
end
describe "#add!" do

0 comments on commit f8085cd

Please sign in to comment.