1 #! /usr/bin/env ruby -S rspec
5 describe Puppet::Parser::Functions.function(:validate_array) do
6 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
7 describe 'when calling validate_array from puppet' do
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/)
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/)
21 it "should compile when multiple array arguments are passed" do
22 Puppet[:code] = <<-'ENDofPUPPETcode'
24 $bar = [ 'one', 'two' ]
25 validate_array($foo, $bar)
27 scope.compiler.compile
30 it "should not compile when an undef variable is passed" do
31 Puppet[:code] = <<-'ENDofPUPPETcode'
35 expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not an Array/)