]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/functions/validate_array_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / validate_array_spec.rb
1 #! /usr/bin/env ruby -S rspec
2
3 require 'spec_helper'
4
5 describe Puppet::Parser::Functions.function(:validate_array) do
6   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
7   describe 'when calling validate_array from puppet' do
8
9     %w{ true false }.each do |the_string|
10       it "should not compile when #{the_string} is a string" do
11         Puppet[:code] = "validate_array('#{the_string}')"
12         expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not an Array/)
13       end
14
15       it "should not compile when #{the_string} is a bare word" do
16         Puppet[:code] = "validate_array(#{the_string})"
17         expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not an Array/)
18       end
19     end
20
21     it "should compile when multiple array arguments are passed" do
22       Puppet[:code] = <<-'ENDofPUPPETcode'
23         $foo = [ ]
24         $bar = [ 'one', 'two' ]
25         validate_array($foo, $bar)
26       ENDofPUPPETcode
27       scope.compiler.compile
28     end
29
30     it "should not compile when an undef variable is passed" do
31       Puppet[:code] = <<-'ENDofPUPPETcode'
32         $foo = undef
33         validate_array($foo)
34       ENDofPUPPETcode
35       expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not an Array/)
36     end
37   end
38 end