Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / concat_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
3
4 describe 'concat function' do
5   describe 'success' do
6     it 'should concat one array to another' do
7       pp = <<-EOS
8       $output = concat(['1','2','3'],['4','5','6'])
9       validate_array($output)
10       if size($output) != 6 {
11         fail("${output} should have 6 elements.")
12       }
13       EOS
14
15       apply_manifest(pp, :catch_failures => true)
16     end
17     it 'should concat arrays and primitives to array' do
18       pp = <<-EOS
19       $output = concat(['1','2','3'],'4','5','6',['7','8','9'])
20       validate_array($output)
21       if size($output) != 9 {
22         fail("${output} should have 9 elements.")
23       }
24       EOS
25
26       apply_manifest(pp, :catch_failures => true)
27     end
28     it 'should concat multiple arrays to one' do
29       pp = <<-EOS
30       $output = concat(['1','2','3'],['4','5','6'],['7','8','9'])
31       validate_array($output)
32       if size($output) != 9 {
33         fail("${output} should have 9 elements.")
34       }
35       EOS
36
37       apply_manifest(pp, :catch_failures => true)
38     end
39     it 'should concat hash arguments' do
40       pp = <<-EOS
41       $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"})
42       validate_array($output)
43       if size($output) != 2 {
44         fail("${output} should have 2 elements.")
45       }
46       if $output[1] != {"c" => "d", "e" => "f"} {
47         fail("${output} does not have the expected hash for the second element.")
48       }
49       EOS
50
51       apply_manifest(pp, :catch_failures => true)
52     end
53   end
54 end