diff --git a/manifests/init.pp b/manifests/init.pp index 077a29bd6..b161e00f1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -104,14 +104,18 @@ true: { $warn_message = $default_warn_message } + # lint:ignore:quoted_booleans 'true', 'yes', 'on': { + # lint:endignore warning($bool_warn_message) $warn_message = $default_warn_message } false: { $warn_message = '' } + # lint:ignore:quoted_booleans 'false', 'no', 'off': { + # lint:endignore warning($bool_warn_message) $warn_message = '' } @@ -246,7 +250,9 @@ # lint:ignore:quoted_booleans $absent_exec_command = $::kernel ? { 'windows' => 'cmd.exe /c exit 0', + # lint:ignore:quoted_booleans default => 'true', + # lint:endignore } # lint:endignore diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index 6cf3e4296..40866a860 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -46,13 +46,21 @@ should contain_file("#{fragdir}/fragments/#{p[:order]}_#{safe_name}").with({ :ensure => safe_ensure, :owner => id, - :group => gid, :mode => '0640', :source => p[:source], :content => p[:content], :alias => "concat_fragment_#{title}", :backup => 'puppet', }) + # The defined() function doesn't seem to work properly with puppet 3.4 and rspec. + # defined() works on its own, rspec works on its own, but together they + # determine that $gid is not defined and cause errors here. Work around + # it by ignoring this check for older puppet version. + if Puppet::Util::Package.versioncmp(Puppet.version, '3.5.0') >= 0 + should contain_file("#{fragdir}/fragments/#{p[:order]}_#{safe_name}").with({ + :group => gid, + }) + end end end @@ -79,7 +87,7 @@ let(:params) {{ :target => false }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) end end end # target => @@ -121,7 +129,7 @@ let(:params) {{ :content => false, :target => '/etc/motd' }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) end end end # content => @@ -142,7 +150,7 @@ let(:params) {{ :source => false, :target => '/etc/motd' }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string or an Array/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a string or an Array/) end end end # source => @@ -163,7 +171,7 @@ let(:params) {{ :order => false, :target => '/etc/motd' }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string or integer/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a string or integer/) end end @@ -173,7 +181,7 @@ let(:params) {{ :order => '123:456', :target => '/etc/motd' }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /cannot contain/) + expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) end end context '123/456' do @@ -182,7 +190,7 @@ let(:params) {{ :order => '123/456', :target => '/etc/motd' }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /cannot contain/) + expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) end end context '123\n456' do @@ -191,7 +199,7 @@ let(:params) {{ :order => "123\n456", :target => '/etc/motd' }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /cannot contain/) + expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) end end end # order => @@ -219,7 +227,7 @@ end it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) + expect { catalogue }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) end end @@ -243,7 +251,7 @@ end it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) + expect { catalogue }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) end end @@ -267,7 +275,7 @@ end it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) + expect { catalogue }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) end end diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 115a0f55b..b5dd25308 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -175,7 +175,7 @@ context title do let(:title) { title } it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not an absolute path/) + expect { catalogue }.to raise_error(Puppet::Error, /is not an absolute path/) end end end @@ -205,7 +205,7 @@ let(:title) { '/etc/foo.bar' } let(:params) {{ :ensure => 'invalid' }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^present$|^absent$"')}/) + expect { catalogue }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^present$|^absent$"')}/) end end end # ensure => @@ -220,7 +220,7 @@ let(:title) { '/etc/foo.bar' } let(:params) {{ :path => path }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not an absolute path/) + expect { catalogue }.to raise_error(Puppet::Error, /is not an absolute path/) end end end @@ -235,7 +235,7 @@ let(:title) { '/etc/foo.bar' } let(:params) {{ :owner => false }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) end end end # owner => @@ -249,7 +249,7 @@ let(:title) { '/etc/foo.bar' } let(:params) {{ :group => false }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) end end end # group => @@ -263,7 +263,7 @@ let(:title) { '/etc/foo.bar' } let(:params) {{ :mode => false }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) end end end # mode => @@ -291,7 +291,7 @@ let(:title) { '/etc/foo.bar' } let(:params) {{ :warn => 123 }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string or boolean/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a string or boolean/) end end end # warn => @@ -307,7 +307,7 @@ let(:title) { '/etc/foo.bar' } let(:params) {{ :force => 123 }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a boolean/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/) end end end # force => @@ -329,7 +329,7 @@ let(:title) { '/etc/foo.bar' } let(:params) {{ :backup => [] }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /backup must be string or bool/) + expect { catalogue }.to raise_error(Puppet::Error, /backup must be string or bool/) end end end # backup => @@ -345,7 +345,7 @@ let(:title) { '/etc/foo.bar' } let(:params) {{ :replace => 123 }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a boolean/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/) end end end # replace => @@ -361,7 +361,7 @@ let(:title) { '/etc/foo.bar' } let(:params) {{ :order => 'invalid' }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^alpha$|^numeric$"')}/) + expect { catalogue }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^alpha$|^numeric$"')}/) end end end # order => @@ -377,22 +377,24 @@ let(:title) { '/etc/foo.bar' } let(:params) {{ :ensure_newline => 123 }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a boolean/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/) end end end # ensure_newline => context 'validate_cmd =>' do - context '/usr/bin/test -e %' do - it_behaves_like 'concat', '/etc/foo.bar', { :validate_cmd => '/usr/bin/test -e %' } - end + if Puppet::Util::Package::versioncmp(Puppet::version, '3.5.0') > 0 + context '/usr/bin/test -e %' do + it_behaves_like 'concat', '/etc/foo.bar', { :validate_cmd => '/usr/bin/test -e %' } + end - [ 1234, true ].each do |cmd| - context cmd do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :validate_cmd => cmd }} - it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /\$validate_cmd must be a string/) + [ 1234, true ].each do |cmd| + context cmd do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :validate_cmd => cmd }} + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /\$validate_cmd must be a string/) + end end end end