1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
4 describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
6 it 'should create an empty array' do
9 $output = any2array($input)
10 validate_array($output)
11 notify { "Output: ${output}": }
14 apply_manifest(pp, :catch_failures => true) do |r|
15 expect(r.stdout).to match(/Notice: Output: /)
19 it 'should leave arrays modified' do
21 $input = ['test', 'array']
22 $output = any2array($input)
23 validate_array($output)
24 notify { "Output: ${output}": }
27 apply_manifest(pp, :catch_failures => true) do |r|
28 expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/)
32 it 'should turn a hash into an array' do
34 $input = {'test' => 'array'}
35 $output = any2array($input)
37 validate_array($output)
38 # Check each element of the array is a plain string.
39 validate_string($output[0])
40 validate_string($output[1])
41 notify { "Output: ${output}": }
44 apply_manifest(pp, :catch_failures => true) do |r|
45 expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/)