summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/util/external_iterator_spec.rb
diff options
context:
space:
mode:
authorChris Price <chris@pupppetlabs.com>2012-08-17 04:48:28 -0700
committerChris Price <chris@pupppetlabs.com>2012-08-17 04:48:28 -0700
commitc57dab4903a6a23fb14dc79c76efea989e694460 (patch)
tree6f8ef871f02465d21b231e931eba03739422d277 /spec/unit/puppet/util/external_iterator_spec.rb
parent4f0e7264e3c3089e489d05bbb4371c449b0ed78d (diff)
downloadpuppet-inifile-c57dab4903a6a23fb14dc79c76efea989e694460.tar.gz
puppet-inifile-c57dab4903a6a23fb14dc79c76efea989e694460.tar.bz2
Add support for "global" section at beginning of file
This commit does the following: * Fixes a bug in ExternalIterator * Adds support for a "global" section before the first named section at the beginning of the INI file * Improves test coverage
Diffstat (limited to 'spec/unit/puppet/util/external_iterator_spec.rb')
-rw-r--r--spec/unit/puppet/util/external_iterator_spec.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/unit/puppet/util/external_iterator_spec.rb b/spec/unit/puppet/util/external_iterator_spec.rb
new file mode 100644
index 0000000..92b17af
--- /dev/null
+++ b/spec/unit/puppet/util/external_iterator_spec.rb
@@ -0,0 +1,35 @@
+require 'spec_helper'
+require 'puppet/util/external_iterator'
+
+describe Puppet::Util::ExternalIterator do
+ let(:subject) { Puppet::Util::ExternalIterator.new(["a", "b", "c"]) }
+
+ context "#next" do
+ it "should iterate over the items" do
+ subject.next.should == ["a", 0]
+ subject.next.should == ["b", 1]
+ subject.next.should == ["c", 2]
+ end
+ end
+
+ context "#peek" do
+ it "should return the 0th item repeatedly" do
+ subject.peek.should == ["a", 0]
+ subject.peek.should == ["a", 0]
+ end
+
+ it "should not advance the iterator, but should reflect calls to #next" do
+ subject.peek.should == ["a", 0]
+ subject.peek.should == ["a", 0]
+ subject.next.should == ["a", 0]
+ subject.peek.should == ["b", 1]
+ subject.next.should == ["b", 1]
+ subject.peek.should == ["c", 2]
+ subject.next.should == ["c", 2]
+ subject.peek.should == [nil, nil]
+ subject.next.should == [nil, nil]
+ end
+ end
+
+
+end