Skip to content

Commit d1eeeea

Browse files
nobueregon
authored andcommitted
Thread::Queue.new should accept an Enumerable [Feature #17327]
Enumerable implements #to_a but not #to_array.
1 parent ff4ad11 commit d1eeeea

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

core/queue/initialize_spec.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
q.should.empty?
1919
end
2020

21-
it "uses #to_ary on the provided Enumerable" do
21+
it "uses #to_a on the provided Enumerable" do
2222
enumerable = MockObject.new('mock-enumerable')
23-
enumerable.should_receive(:to_ary).and_return([1, 2, 3])
23+
enumerable.should_receive(:to_a).and_return([1, 2, 3])
2424
q = Queue.new(enumerable)
2525
q.size.should == 3
2626
q.should_not.empty?
@@ -30,15 +30,9 @@
3030
q.should.empty?
3131
end
3232

33-
it "raises if the provided Enumerable does not respond to #to_ary" do
33+
it "raises if the provided Enumerable does not respond to #to_a" do
3434
enumerable = MockObject.new('mock-enumerable')
35-
-> { Queue.new(enumerable) }.should raise_error(TypeError, "no implicit conversion of MockObject into Array")
36-
end
37-
38-
it "raises if the provided Enumerable #to_ary does not return an Array" do
39-
enumerable = MockObject.new('mock-enumerable')
40-
enumerable.should_receive(:to_ary).and_return(14)
41-
-> { Queue.new(enumerable) }.should raise_error(TypeError, "can't convert MockObject to Array (MockObject#to_ary gives Integer)")
35+
-> { Queue.new(enumerable) }.should raise_error(TypeError, "can't convert MockObject into Array")
4236
end
4337
end
4438
end

0 commit comments

Comments
 (0)