2 require 'puppet/util/external_iterator'
4 describe Puppet::Util::ExternalIterator do
5 let(:subject) { Puppet::Util::ExternalIterator.new(["a", "b", "c"]) }
8 it "should iterate over the items" do
9 subject.next.should == ["a", 0]
10 subject.next.should == ["b", 1]
11 subject.next.should == ["c", 2]
16 it "should return the 0th item repeatedly" do
17 subject.peek.should == ["a", 0]
18 subject.peek.should == ["a", 0]
21 it "should not advance the iterator, but should reflect calls to #next" do
22 subject.peek.should == ["a", 0]
23 subject.peek.should == ["a", 0]
24 subject.next.should == ["a", 0]
25 subject.peek.should == ["b", 1]
26 subject.next.should == ["b", 1]
27 subject.peek.should == ["c", 2]
28 subject.next.should == ["c", 2]
29 subject.peek.should == [nil, nil]
30 subject.next.should == [nil, nil]