comparison modules/stdlib/spec/functions/getvar_spec.rb @ 37:addb0ea390a1 puppet-3.6

Update Puppet "stdlib" module
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2015 20:09:45 +0000
parents
children c42fb28cff86
comparison
equal deleted inserted replaced
36:37675581a273 37:addb0ea390a1
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