]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/functions/getvar_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / getvar_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 describe Puppet::Parser::Functions.function(:getvar) do
5   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6   describe 'when calling getvar from puppet' do
7
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()'
11       expect {
12         scope.compiler.compile
13       }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
14     end
15
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")'
19       expect {
20         scope.compiler.compile
21       }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
22     end
23
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' }
28         include site::data
29         $foo = getvar("site::data::foo")
30         if $foo != 'baz' {
31           fail('getvar did not return what we expect')
32         }
33       ENDofPUPPETcode
34       scope.compiler.compile
35     end
36   end
37 end