]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/inifile/spec/unit/puppet/util/external_iterator_spec.rb
add puppetlabs/inifile to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / inifile / spec / unit / puppet / util / external_iterator_spec.rb
1 require 'spec_helper'
2 require 'puppet/util/external_iterator'
3
4 describe Puppet::Util::ExternalIterator do
5   let(:subject) { Puppet::Util::ExternalIterator.new(["a", "b", "c"]) }
6
7   context "#next" do
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]      
12     end
13   end
14
15   context "#peek" do
16     it "should return the 0th item repeatedly" do
17       subject.peek.should == ["a", 0]
18       subject.peek.should == ["a", 0]
19     end
20     
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]
31     end
32   end
33
34
35 end