Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / any2array_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'any2array function' do
4   describe 'success' do
5     pp1 = <<-DOC
6       $input = ''
7       $output = any2array($input)
8       validate_array($output)
9       notify { "Output: ${output}": }
10     DOC
11     it 'creates an empty array' do
12       apply_manifest(pp1, :catch_failures => true) do |r|
13         expect(r.stdout).to match(%r{Notice: Output: })
14       end
15     end
16
17     pp2 = <<-DOC
18       $input = ['array', 'test']
19       $output = any2array($input)
20       validate_array($output)
21       notify { "Output: ${output}": }
22     DOC
23     it 'leaves arrays modified' do
24       apply_manifest(pp2, :catch_failures => true) do |r|
25         expect(r.stdout).to match(%r{Notice: Output: (\[|)array(,\s|)test(\]|)})
26       end
27     end
28
29     pp3 = <<-DOC
30       $input = {'test' => 'array'}
31       $output = any2array($input)
32
33       validate_array($output)
34       # Check each element of the array is a plain string.
35       validate_string($output[0])
36       validate_string($output[1])
37       notify { "Output: ${output}": }
38     DOC
39     it 'turns a hash into an array' do
40       apply_manifest(pp3, :catch_failures => true) do |r|
41         expect(r.stdout).to match(%r{Notice: Output: (\[|)test(,\s|)array(\]|)})
42       end
43     end
44   end
45 end