1 #! /usr/bin/env ruby -S rspec
5 describe Puppet::Parser::Functions.function(:validate_hash) do
6 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 describe 'when calling validate_hash from puppet' do
10 %w{ true false }.each do |the_string|
12 it "should not compile when #{the_string} is a string" do
13 Puppet[:code] = "validate_hash('#{the_string}')"
14 expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not a Hash/)
17 it "should not compile when #{the_string} is a bare word" do
18 Puppet[:code] = "validate_hash(#{the_string})"
19 expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not a Hash/)
24 it "should compile when multiple hash arguments are passed" do
25 Puppet[:code] = <<-'ENDofPUPPETcode'
27 $bar = { 'one' => 'two' }
28 validate_hash($foo, $bar)
30 scope.compiler.compile
33 it "should not compile when an undef variable is passed" do
34 Puppet[:code] = <<-'ENDofPUPPETcode'
38 expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not a Hash/)