1 #! /usr/bin/env ruby -S rspec
4 describe Puppet::Parser::Functions.function(:getvar) do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6 describe 'when calling getvar from puppet' do
8 it "should not compile when no arguments are passed" do
9 skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
10 Puppet[:code] = '$foo = getvar()'
12 scope.compiler.compile
13 }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
16 it "should not compile when too many arguments are passed" do
17 skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
18 Puppet[:code] = '$foo = getvar("foo::bar", "baz")'
20 scope.compiler.compile
21 }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
24 it "should lookup variables in other namespaces" do
25 skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
26 Puppet[:code] = <<-'ENDofPUPPETcode'
27 class site::data { $foo = 'baz' }
29 $foo = getvar("site::data::foo")
31 fail('getvar did not return what we expect')
34 scope.compiler.compile