X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Ffunctions%2Fgetvar_spec.rb;fp=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Ffunctions%2Fgetvar_spec.rb;h=6c37baafa981c8692eaa7217073345fb8b8f12aa;hb=131e09855e065be940e104d9ab0f18940cc76257;hp=55789d85ac2569fd60ebbfe2dc83deffb403f31a;hpb=407d322498f4fde815abf381007fbecfe5c10b2b;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/spec/functions/getvar_spec.rb b/3rdparty/modules/stdlib/spec/functions/getvar_spec.rb old mode 100755 new mode 100644 index 55789d85a..6c37baafa --- a/3rdparty/modules/stdlib/spec/functions/getvar_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/getvar_spec.rb @@ -2,37 +2,44 @@ require 'spec_helper' 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) } - it { is_expected.to run.with_params('$::foo').and_return(nil) } + describe 'before Puppet 6.0.0', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } + it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } + end + + describe 'from Puppet 6.0.0', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') >= 0 do + it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{expects between 1 and 2 arguments, got none}i) } + it { is_expected.to run.with_params('one', 'two').and_return('two') } + it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(ArgumentError, %r{expects between 1 and 2 arguments, got 3}i) } + end - context 'given variables in namespaces' do - let(:pre_condition) { - <<-'ENDofPUPPETcode' + it { is_expected.to run.with_params('::foo').and_return(nil) } + + context 'with given variables in namespaces' do + let(:pre_condition) do + <<-PUPPETCODE class site::data { $foo = 'baz' } include site::data - ENDofPUPPETcode - } + PUPPETCODE + end 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') } it { is_expected.to run.with_params('::site::data::bar').and_return(nil) } end - context 'given variables in namespaces' do - let(:pre_condition) { - <<-'ENDofPUPPETcode' + context 'with given variables in namespaces' do + let(:pre_condition) do + <<-PUPPETCODE class site::info { $lock = 'ŧҺîš íš ắ śţřĭŋĝ' } class site::new { $item = '万Ü€‰' } include site::info include site::new - ENDofPUPPETcode - } + PUPPETCODE + end it { is_expected.to run.with_params('site::info::lock').and_return('ŧҺîš íš ắ śţřĭŋĝ') } it { is_expected.to run.with_params('::site::new::item').and_return('万Ü€‰') } end end -