external_iterator_spec.rb 982 B

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