]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/functions/zip_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / zip_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 describe "the zip function" do
5   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
7   it "should raise a ParseError if there is less than 1 arguments" do
8     expect { scope.function_zip([]) }.to( raise_error(Puppet::ParseError))
9   end
10
11   it "should be able to zip an array" do
12     result = scope.function_zip([['1','2','3'],['4','5','6']])
13     expect(result).to(eq([["1", "4"], ["2", "5"], ["3", "6"]]))
14     result = scope.function_zip([['1','2','3'],['4','5','6'], false])
15     result.should(eq([["1", "4"], ["2", "5"], ["3", "6"]]))
16   end
17
18   it "should be able to zip an array and flatten" do
19     result = scope.function_zip([['1','2','3'],['4','5','6'], true])
20     result.should(eq(["1", "4", "2", "5", "3", "6"]))
21   end
22
23   it "should accept objects which extend String for the second argument" do
24     class AlsoString < String
25     end
26
27     value = AlsoString.new('false')
28     result = scope.function_zip([['1','2','3'],['4','5','6'],value])
29     result.should(eq([["1", "4"], ["2", "5"], ["3", "6"]]))
30   end
31 end