Skip to content

Commit 448f396

Browse files
committed
Merge pull request ruby#266 from lucasallan/enumerator-peek
Added specs for Enumerator#peek behaviour.
2 parents c625d0c + 1728b8b commit 448f396

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

optional/capi/enumerator_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
enumerator = @s.rb_enumeratorize(@enumerable, :each, :arg1, :arg2)
2626
enumerator.class.should == Enumerator
2727
end
28+
29+
it 'raises an exception when the enumerator position is already at the end' do
30+
e = 2.times
31+
e.peek.should == 0
32+
e.next
33+
e.peek.should == 1
34+
e.next
35+
lambda { e.peek }.should raise_error(StopIteration)
36+
end
2837
end
2938

3039
it "enumerates the given object" do

0 commit comments

Comments
 (0)