From 37748f72fc71d592eed6642d22e73bfe0d93971b Mon Sep 17 00:00:00 2001 From: Steffen Zieger Date: Fri, 5 Aug 2016 09:18:33 +0200 Subject: [PATCH] couple of rubocop changes --- spec/classes/rsyslog_client_spec.rb | 88 ++++++++--------- spec/classes/rsyslog_database_spec.rb | 16 +-- spec/classes/rsyslog_server_spec.rb | 40 ++++---- spec/classes/rsyslog_spec.rb | 52 +++++----- spec/defines/rsyslog_imfile_spec.rb | 12 +-- spec/defines/rsyslog_snippet_spec.rb | 135 ++++++++++---------------- spec/spec_helper.rb | 8 +- 7 files changed, 160 insertions(+), 191 deletions(-) diff --git a/spec/classes/rsyslog_client_spec.rb b/spec/classes/rsyslog_client_spec.rb index 6b41765..c015583 100644 --- a/spec/classes/rsyslog_client_spec.rb +++ b/spec/classes/rsyslog_client_spec.rb @@ -21,7 +21,7 @@ describe 'rsyslog::client', :type => :class do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-client-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/client.conf') end end @@ -30,19 +30,19 @@ describe 'rsyslog::client', :type => :class do let(:title) { 'rsyslog-client-basic' } let(:params) {{ :split_config => true }} - it 'should not manage client.conf' do + it 'does not manage client.conf' do should_not contain_file('/etc/rsyslog.d/client.conf') end - it 'should configure client' do + it 'configures client' do should contain_file('/etc/rsyslog.d/00_client_config.conf').with_ensure('present') end - it 'should configure client remote logging' do + it 'configures client remote logging' do should contain_file('/etc/rsyslog.d/50_client_remote.conf').with_ensure('present') end - it 'should remove client local logging' do + it 'removes client local logging' do should contain_file('/etc/rsyslog.d/99_client_local.conf').with_ensure('absent') end end @@ -51,7 +51,7 @@ describe 'rsyslog::client', :type => :class do let(:title) { 'log_filters_check' } let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/client.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log}) end end @@ -68,7 +68,7 @@ describe 'rsyslog::client', :type => :class do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-client-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/client.conf') end end @@ -77,19 +77,19 @@ describe 'rsyslog::client', :type => :class do let(:title) { 'rsyslog-client-basic' } let(:params) {{ :split_config => true }} - it 'should not manage client.conf' do + it 'does not manage client.conf' do should_not contain_file('/etc/rsyslog.d/client.conf') end - it 'should configure client' do + it 'configures client' do should contain_file('/etc/rsyslog.d/00_client_config.conf').with_ensure('present') end - it 'should configure client remote logging' do + it 'configures client remote logging' do should contain_file('/etc/rsyslog.d/50_client_remote.conf').with_ensure('present') end - it 'should remove client local logging' do + it 'removes client local logging' do should contain_file('/etc/rsyslog.d/99_client_local.conf').with_ensure('absent') end end @@ -98,7 +98,7 @@ describe 'rsyslog::client', :type => :class do let(:title) { 'log_filters_check' } let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/client.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log}) end end @@ -109,7 +109,7 @@ describe 'rsyslog::client', :type => :class do context "without SSL" do let(:params) { { :ssl_auth_mode => 'x509/name' } } - it 'should fail' do + it 'fails' do expect { should contain_class('rsyslog::client') }.to raise_error(Puppet::Error, /You need to enable SSL in order to use ssl_auth_mode./) end end @@ -124,7 +124,7 @@ describe 'rsyslog::client', :type => :class do context "with default auth_mode" do let(:params) { ssl_params } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/client.conf').with_content(/\$ActionSendStreamDriverAuthMode anon/).without_content(/\$ActionSendStreamDriverPermittedPeer/) end end @@ -136,7 +136,7 @@ describe 'rsyslog::client', :type => :class do }) end - it 'should contain ActionSendStreamDriverAuthMode' do + it 'contains ActionSendStreamDriverAuthMode' do should contain_file('/etc/rsyslog.d/client.conf').with_content(/\$ActionSendStreamDriverAuthMode x509\/name/).without_content(/\$ActionSendStreamDriverPermittedPeer/) end end @@ -148,7 +148,7 @@ describe 'rsyslog::client', :type => :class do }) end - it 'should fail' do + it 'fails' do expect { should contain_class('rsyslog::client') }.to raise_error(Puppet::Error, /You need to set auth_mode to 'x509\/name' in order to use ssl_permitted_peer./) end end @@ -161,7 +161,7 @@ describe 'rsyslog::client', :type => :class do }) end - it 'should contain ActionSendStreamDriverPermittedPeer' do + it 'contains ActionSendStreamDriverPermittedPeer' do should contain_file('/etc/rsyslog.d/client.conf').with_content(/\$ActionSendStreamDriverAuthMode x509\/name/).with_content(/\$ActionSendStreamDriverPermittedPeer logs.example.com/) end end @@ -180,7 +180,7 @@ describe 'rsyslog::client', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-client-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/client.conf') end end @@ -189,19 +189,19 @@ describe 'rsyslog::client', :type => :class do let(:title) { 'rsyslog-client-basic' } let(:params) {{ :split_config => true }} - it 'should not manage client.conf' do + it 'does not manage client.conf' do should_not contain_file('/usr/local/etc/rsyslog.d/client.conf') end - it 'should configure client' do + it 'configures client' do should contain_file('/usr/local/etc/rsyslog.d/00_client_config.conf').with_ensure('present') end - it 'should configure client remote logging' do + it 'configures client remote logging' do should contain_file('/usr/local/etc/rsyslog.d/50_client_remote.conf').with_ensure('present') end - it 'should remove client local logging' do + it 'removes client local logging' do should contain_file('/usr/local/etc/rsyslog.d/99_client_local.conf').with_ensure('absent') end end @@ -227,7 +227,7 @@ describe 'rsyslog::client', :type => :class do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-client-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/client.conf') end end @@ -236,19 +236,19 @@ describe 'rsyslog::client', :type => :class do let(:title) { 'rsyslog-client-basic' } let(:params) {{ :split_config => true }} - it 'should not manage client.conf' do + it 'does not manage client.conf' do should_not contain_file('/etc/rsyslog.d/client.conf') end - it 'should configure client' do + it 'configures client' do should contain_file('/etc/rsyslog.d/00_client_config.conf').with_ensure('present') end - it 'should configure client remote logging' do + it 'configures client remote logging' do should contain_file('/etc/rsyslog.d/50_client_remote.conf').with_ensure('present') end - it 'should remove client local logging' do + it 'removes client local logging' do should contain_file('/etc/rsyslog.d/99_client_local.conf').with_ensure('absent') end end @@ -257,7 +257,7 @@ describe 'rsyslog::client', :type => :class do let(:title) { 'log_filters_check' } let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/client.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log}) end end @@ -274,7 +274,7 @@ describe 'rsyslog::client', :type => :class do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-client-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/client.conf') end end @@ -283,19 +283,19 @@ describe 'rsyslog::client', :type => :class do let(:title) { 'rsyslog-client-basic' } let(:params) {{ :split_config => true }} - it 'should not manage client.conf' do + it 'does not manage client.conf' do should_not contain_file('/etc/rsyslog.d/client.conf') end - it 'should configure client' do + it 'configures client' do should contain_file('/etc/rsyslog.d/00_client_config.conf').with_ensure('present') end - it 'should configure client remote logging' do + it 'configures client remote logging' do should contain_file('/etc/rsyslog.d/50_client_remote.conf').with_ensure('present') end - it 'should remove client local logging' do + it 'removes client local logging' do should contain_file('/etc/rsyslog.d/99_client_local.conf').with_ensure('absent') end end @@ -304,7 +304,7 @@ describe 'rsyslog::client', :type => :class do let(:title) { 'log_filters_check' } let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/client.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log}) end end @@ -321,7 +321,7 @@ describe 'rsyslog::client', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-client-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/client.conf') end end @@ -330,19 +330,19 @@ describe 'rsyslog::client', :type => :class do let(:title) { 'rsyslog-client-basic' } let(:params) {{ :split_config => true }} - it 'should not manage client.conf' do + it 'does not manage client.conf' do should_not contain_file('/usr/local/etc/rsyslog.d/client.conf') end - it 'should configure client' do + it 'configures client' do should contain_file('/usr/local/etc/rsyslog.d/00_client_config.conf').with_ensure('present') end - it 'should configure client remote logging' do + it 'configures client remote logging' do should contain_file('/usr/local/etc/rsyslog.d/50_client_remote.conf').with_ensure('present') end - it 'should remove client local logging' do + it 'removes client local logging' do should contain_file('/usr/local/etc/rsyslog.d/99_client_local.conf').with_ensure('absent') end end @@ -368,7 +368,7 @@ describe 'rsyslog::client', :type => :class do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-client-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/client.conf') end end @@ -377,19 +377,19 @@ describe 'rsyslog::client', :type => :class do let(:title) { 'rsyslog-client-basic' } let(:params) {{ :split_config => true }} - it 'should not manage client.conf' do + it 'does not manage client.conf' do should_not contain_file('/etc/rsyslog.d/client.conf') end - it 'should configure client' do + it 'configures client' do should contain_file('/etc/rsyslog.d/00_client_config.conf').with_ensure('present') end - it 'should configure client remote logging' do + it 'configures client remote logging' do should contain_file('/etc/rsyslog.d/50_client_remote.conf').with_ensure('present') end - it 'should remove client local logging' do + it 'removes client local logging' do should contain_file('/etc/rsyslog.d/99_client_local.conf').with_ensure('absent') end end diff --git a/spec/classes/rsyslog_database_spec.rb b/spec/classes/rsyslog_database_spec.rb index 78011b6..709ae7b 100644 --- a/spec/classes/rsyslog_database_spec.rb +++ b/spec/classes/rsyslog_database_spec.rb @@ -31,7 +31,7 @@ describe 'rsyslog::database', :type => :class do } } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog-mysql') should contain_file('/etc/rsyslog.d/mysql.conf') end @@ -50,7 +50,7 @@ describe 'rsyslog::database', :type => :class do } } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog-pgsql') should contain_file('/etc/rsyslog.d/pgsql.conf') end @@ -80,7 +80,7 @@ describe 'rsyslog::database', :type => :class do } } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog-mysql') should contain_file('/etc/rsyslog.d/mysql.conf') end @@ -99,7 +99,7 @@ describe 'rsyslog::database', :type => :class do } } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog-pgsql') should contain_file('/etc/rsyslog.d/pgsql.conf') end @@ -136,7 +136,7 @@ describe 'rsyslog::database', :type => :class do } } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog-mysql') should contain_file('/etc/rsyslog.d/mysql.conf') end @@ -155,7 +155,7 @@ describe 'rsyslog::database', :type => :class do } } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog-pgsql') should contain_file('/etc/rsyslog.d/pgsql.conf') end @@ -185,7 +185,7 @@ describe 'rsyslog::database', :type => :class do } } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog-mysql') should contain_file('/etc/rsyslog.d/mysql.conf') end @@ -204,7 +204,7 @@ describe 'rsyslog::database', :type => :class do } } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog-pgsql') should contain_file('/etc/rsyslog.d/pgsql.conf') end diff --git a/spec/classes/rsyslog_server_spec.rb b/spec/classes/rsyslog_server_spec.rb index c260aad..1862a8a 100644 --- a/spec/classes/rsyslog_server_spec.rb +++ b/spec/classes/rsyslog_server_spec.rb @@ -22,7 +22,7 @@ describe 'rsyslog::server', :type => :class do context "default usage (osfamily = #{osfamily})" do let(:title) { 'rsyslog-server-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -32,7 +32,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'enable_onefile' => 'true'} } - it 'should compile' do + it 'compiles' do should_not contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -42,7 +42,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/) should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/) end @@ -52,7 +52,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'log_filters_check' } let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log}) end end @@ -71,7 +71,7 @@ describe 'rsyslog::server', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-server-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -81,7 +81,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'enable_onefile' => 'true'} } - it 'should compile' do + it 'compiles' do should_not contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -91,7 +91,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/) should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/) end @@ -120,7 +120,7 @@ describe 'rsyslog::server', :type => :class do context "default usage (osfamily = #{osfamily})" do let(:title) { 'rsyslog-server-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -130,7 +130,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'enable_onefile' => 'true'} } - it 'should compile' do + it 'compiles' do should_not contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -140,7 +140,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/) should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/) end @@ -150,7 +150,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'log_filters_check' } let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log}) end end @@ -169,7 +169,7 @@ describe 'rsyslog::server', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-server-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -179,7 +179,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'enable_onefile' => 'true'} } - it 'should compile' do + it 'compiles' do should_not contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -189,7 +189,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/) should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/) end @@ -218,7 +218,7 @@ describe 'rsyslog::server', :type => :class do context "default usage (osfamily = #{osfamily})" do let(:title) { 'rsyslog-server-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -228,7 +228,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'enable_onefile' => 'true'} } - it 'should compile' do + it 'compiles' do should_not contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -238,7 +238,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/) should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/) end @@ -259,7 +259,7 @@ describe 'rsyslog::server', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-server-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -269,7 +269,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'enable_onefile' => 'true'} } - it 'should compile' do + it 'compiles' do should_not contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) end @@ -279,7 +279,7 @@ describe 'rsyslog::server', :type => :class do let(:title) { 'rsyslog-server-onefile' } let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/) should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/) end diff --git a/spec/classes/rsyslog_spec.rb b/spec/classes/rsyslog_spec.rb index 3d8e221..42240bf 100644 --- a/spec/classes/rsyslog_spec.rb +++ b/spec/classes/rsyslog_spec.rb @@ -21,7 +21,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_class('rsyslog::install') should contain_class('rsyslog::config') should contain_class('rsyslog::service') @@ -40,7 +40,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_class('rsyslog::install') should contain_class('rsyslog::config') should contain_class('rsyslog::service') @@ -59,7 +59,7 @@ describe 'rsyslog', :type => :class do context "when set" do let(:params) { { :local_host_name => 'example.dev' } } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.conf').with_content(/\$LocalHostName example.dev/) end end @@ -77,7 +77,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_class('rsyslog::install') should contain_class('rsyslog::config') should contain_class('rsyslog::service') @@ -97,7 +97,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.conf') should contain_file('/etc/rsyslog.d/') end @@ -115,7 +115,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.conf') should contain_file('/etc/rsyslog.d/') end @@ -133,7 +133,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.conf') should contain_file('/usr/local/etc/rsyslog.d/') end @@ -152,7 +152,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-install-basic' } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog') should contain_package('rsyslog-relp') end @@ -170,7 +170,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-install-basic' } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog') should contain_package('rsyslog-relp') end @@ -188,7 +188,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-install-basic' } - it 'should compile' do + it 'compiles' do should contain_package('sysutils/rsyslog8') end end @@ -206,7 +206,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-service-basic' } - it 'should compile' do + it 'compiles' do should contain_service('rsyslog') end end @@ -223,7 +223,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-service-basic' } - it 'should compile' do + it 'compiles' do should contain_service('rsyslog') end end @@ -240,7 +240,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-service-basic' } - it 'should compile' do + it 'compiles' do should contain_service('rsyslogd') end end @@ -266,7 +266,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_class('rsyslog::install') should contain_class('rsyslog::config') should contain_class('rsyslog::service') @@ -285,7 +285,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_class('rsyslog::install') should contain_class('rsyslog::config') should contain_class('rsyslog::service') @@ -304,7 +304,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_class('rsyslog::install') should contain_class('rsyslog::config') should contain_class('rsyslog::service') @@ -324,7 +324,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.conf') should contain_file('/etc/rsyslog.d/') end @@ -342,7 +342,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.conf') should contain_file('/etc/rsyslog.d/') end @@ -360,7 +360,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.conf') should contain_file('/usr/local/etc/rsyslog.d/') end @@ -379,7 +379,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-install-basic' } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog') should contain_package('rsyslog-relp') end @@ -397,7 +397,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-install-basic' } - it 'should compile' do + it 'compiles' do should contain_package('rsyslog') should contain_package('rsyslog-relp') end @@ -415,7 +415,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-install-basic' } - it 'should compile' do + it 'compiles' do should contain_package('sysutils/rsyslog8') end end @@ -433,7 +433,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-service-basic' } - it 'should compile' do + it 'compiles' do should contain_service('rsyslog') end end @@ -450,7 +450,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-service-basic' } - it 'should compile' do + it 'compiles' do should contain_service('rsyslog') end end @@ -467,7 +467,7 @@ describe 'rsyslog', :type => :class do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-service-basic' } - it 'should compile' do + it 'compiles' do should contain_service('rsyslogd') end end @@ -491,7 +491,7 @@ describe 'rsyslog', :type => :class do end context "default usage (osfamily = RedHat)" do - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.conf') should contain_file('/etc/rsyslog.d/') end diff --git a/spec/defines/rsyslog_imfile_spec.rb b/spec/defines/rsyslog_imfile_spec.rb index 0d2be8c..d217a28 100644 --- a/spec/defines/rsyslog_imfile_spec.rb +++ b/spec/defines/rsyslog_imfile_spec.rb @@ -29,7 +29,7 @@ describe 'rsyslog::imfile', :type => :define do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-imfile-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/rsyslog-imfile-basic.conf') end end @@ -54,7 +54,7 @@ describe 'rsyslog::imfile', :type => :define do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-imfile-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/rsyslog-imfile-basic.conf') end end @@ -79,7 +79,7 @@ describe 'rsyslog::imfile', :type => :define do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-imfile-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/rsyslog-imfile-basic.conf') end end @@ -113,7 +113,7 @@ describe 'rsyslog::imfile', :type => :define do context "default usage (osfamily = RedHat)" do let(:title) { 'rsyslog-imfile-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/rsyslog-imfile-basic.conf') end end @@ -138,7 +138,7 @@ describe 'rsyslog::imfile', :type => :define do context "default usage (osfamily = Debian)" do let(:title) { 'rsyslog-imfile-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/rsyslog-imfile-basic.conf') end end @@ -163,7 +163,7 @@ describe 'rsyslog::imfile', :type => :define do context "default usage (osfamily = FreeBSD)" do let(:title) { 'rsyslog-imfile-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/rsyslog-imfile-basic.conf') end end diff --git a/spec/defines/rsyslog_snippet_spec.rb b/spec/defines/rsyslog_snippet_spec.rb index 17a3982..638198e 100644 --- a/spec/defines/rsyslog_snippet_spec.rb +++ b/spec/defines/rsyslog_snippet_spec.rb @@ -1,166 +1,137 @@ require 'spec_helper' -describe 'rsyslog::snippet', :type => :define do - - context "Rsyslog version >= 8" do +describe 'rsyslog::snippet', type: :define do + context 'Rsyslog version >= 8' do let(:default_facts) do { - :rsyslog_version => '8.1.2' + rsyslog_version: '8.1.2' } end - context "osfamily = RedHat" do + context 'osfamily = RedHat' do let :facts do - default_facts.merge!({ - :osfamily => 'RedHat', - :operatingsystem => 'Redhat', - :operatingsystemmajrelease => '6', - }) + default_facts.merge!( + osfamily: 'RedHat', + operatingsystem: 'Redhat', + operatingsystemmajrelease: '6' + ) end - let (:params) { - { - 'content' => 'Random Content', - } - } + let(:params) { { 'content' => 'Random Content' } } - context "default usage (osfamily = RedHat)" do + context 'default usage (osfamily = RedHat)' do let(:title) { 'rsyslog-snippet-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n") end let(:title) { 'rsyslog/snippet/basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n") end end end - context "osfamily = Debian" do + context 'osfamily = Debian' do let :facts do - default_facts.merge!({ - :osfamily => 'Debian', - :operatingsystem => 'Debian', - }) + default_facts.merge!( + osfamily: 'Debian', + operatingsystem: 'Debian' + ) end - let (:params) { - { - 'content' => 'Random Content', - } - } + let(:params) { { 'content' => 'Random Content' } } - context "default usage (osfamily = Debian)" do + context 'default usage (osfamily = Debian)' do let(:title) { 'rsyslog-snippet-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n") end end end - context "osfamily = FreeBSD" do + context 'osfamily = FreeBSD' do let :facts do - default_facts.merge!({ - :osfamily => 'FreeBSD', - :operatingsystem => 'FreeBSD', - }) + default_facts.merge!( + osfamily: 'FreeBSD', + operatingsystem: 'FreeBSD' + ) end - let (:params) { - { - 'content' => 'Random Content', - } - } + let(:params) { { 'content' => 'Random Content' } } - context "default usage (osfamily = FreeBSD)" do + context 'default usage (osfamily = FreeBSD)' do let(:title) { 'rsyslog-snippet-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n") end end end end - context "Rsyslog version =< 8" do + context 'Rsyslog version =< 8' do let(:default_facts) do { - :rsyslog_version => '7.1.2' + rsyslog_version: '7.1.2' } end - context "osfamily = RedHat" do + context 'osfamily = RedHat' do let :facts do - default_facts.merge!({ - :osfamily => 'RedHat', - :operatingsystem => 'Redhat', - :operatingsystemmajrelease => '6', - }) + default_facts.merge!( + osfamily: 'RedHat', + operatingsystem: 'Redhat', + operatingsystemmajrelease: '6' + ) end - let (:params) { - { - 'content' => 'Random Content', - } - } + let(:params) { { 'content' => 'Random Content' } } - context "default usage (osfamily = RedHat)" do + context 'default usage (osfamily = RedHat)' do let(:title) { 'rsyslog-snippet-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n") end end end - context "osfamily = Debian" do + context 'osfamily = Debian' do let :facts do - default_facts.merge!({ - :osfamily => 'Debian', - :operatingsystem => 'Debian', - }) + default_facts.merge!( + osfamily: 'Debian', + operatingsystem: 'Debian' + ) end - let (:params) { - { - 'content' => 'Random Content', - } - } + let(:params) { { 'content' => 'Random Content' } } - context "default usage (osfamily = Debian)" do + context 'default usage (osfamily = Debian)' do let(:title) { 'rsyslog-snippet-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/etc/rsyslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n") end end end - context "osfamily = FreeBSD" do + context 'osfamily = FreeBSD' do let :facts do - default_facts.merge!({ - :osfamily => 'FreeBSD', - :operatingsystem => 'FreeBSD', - }) + default_facts.merge!(osfamily: 'FreeBSD', operatingsystem: 'FreeBSD') end - let (:params) { - { - 'content' => 'Random Content', - } - } + let(:params) { { 'content' => 'Random Content' } } - context "default usage (osfamily = FreeBSD)" do + context 'default usage (osfamily = FreeBSD)' do let(:title) { 'rsyslog-snippet-basic' } - it 'should compile' do + it 'compiles' do should contain_file('/usr/local/etc/rsyslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n") end end end end - end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8a90c0d..8309fca 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,9 +6,7 @@ RSpec.configure do |c| end c.include PuppetlabsSpec::Files - if ENV['PARSER'] == 'future' - c.parser = 'future' - end + c.parser = 'future' if ENV['PARSER'] == 'future' c.before :each do # Ensure that we don't accidentally cache facts and environment @@ -19,10 +17,10 @@ RSpec.configure do |c| # Store any environment variables away to be restored later @old_env = {} - ENV.each_key {|k| @old_env[k] = ENV[k]} + ENV.each_key { |k| @old_env[k] = ENV[k] } if Gem::Version.new(`puppet --version`) >= Gem::Version.new('3.5') - Puppet.settings[:strict_variables]=true + Puppet.settings[:strict_variables] = true end end