2012-07-20 01:14:37 +02:00
|
|
|
require 'spec_helper'
|
2011-06-21 23:10:33 +02:00
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
describe 'getvar' do
|
|
|
|
it { is_expected.not_to eq(nil) }
|
|
|
|
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
|
|
|
|
it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
|
|
|
|
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
|
2011-06-21 23:10:33 +02:00
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
context 'given variables in namespaces' do
|
|
|
|
let(:pre_condition) {
|
|
|
|
<<-'ENDofPUPPETcode'
|
|
|
|
class site::data { $foo = 'baz' }
|
|
|
|
include site::data
|
|
|
|
ENDofPUPPETcode
|
|
|
|
}
|
2012-08-09 23:18:30 +02:00
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
it { is_expected.to run.with_params('site::data::foo').and_return('baz') }
|
|
|
|
it { is_expected.to run.with_params('::site::data::foo').and_return('baz') }
|
|
|
|
|
|
|
|
context 'with strict variable checking', :if => RSpec.configuration.strict_variables do
|
|
|
|
it { is_expected.to run.with_params('::site::data::bar').and_raise_error(ArgumentError, /undefined_variable/) }
|
2011-06-21 23:10:33 +02:00
|
|
|
end
|
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
context 'without strict variable checking', :unless => RSpec.configuration.strict_variables do
|
|
|
|
it { is_expected.to run.with_params('::site::data::bar').and_return(nil) }
|
2011-06-21 23:10:33 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|