From afb78e2b253dfe43816e20afa2f4732eb9dc17eb Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 13 Mar 2014 18:21:38 +0000 Subject: Add some acceptance tests for functions. --- spec/acceptance/any2array_spec.rb | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 spec/acceptance/any2array_spec.rb (limited to 'spec/acceptance/any2array_spec.rb') diff --git a/spec/acceptance/any2array_spec.rb b/spec/acceptance/any2array_spec.rb new file mode 100644 index 0000000..7d452ed --- /dev/null +++ b/spec/acceptance/any2array_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper_acceptance' + +describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do + it 'should create an empty array' do + pp = <<-EOS + $input = '' + $output = any2array($input) + validate_array($output) + notify { "Output: ${output}": } + EOS + + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/Notice: Output: /) + end + end + + it 'should leave arrays modified' do + pp = <<-EOS + $input = ['test', 'array'] + $output = any2array($input) + validate_array($output) + notify { "Output: ${output}": } + EOS + + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/Notice: Output: testarray/) + end + end + + it 'should turn a hash into an array' do + pp = <<-EOS + $input = {'test' => 'array'} + $output = any2array($input) + + validate_array($output) + # Check each element of the array is a plain string. + validate_string($output[0]) + validate_string($output[1]) + notify { "Output: ${output}": } + EOS + + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/Notice: Output: testarray/) + end + end +end -- cgit v1.2.3