From c852dc22d77803d629813917054dd83946d7e0eb Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Tue, 5 Nov 2013 20:40:03 -0700 Subject: [PATCH] clean up between system spec files --- spec/spec_helper_system.rb | 7 +++++ spec/system/concat_spec.rb | 32 ++++++++++---------- spec/system/deprecation_warnings_spec.rb | 20 ++++++------- spec/system/empty_spec.rb | 4 +-- spec/system/fragment_list_source_spec.rb | 38 ++++++++++++------------ spec/system/replace_spec.rb | 8 ++--- spec/system/symbolic_name_spec.rb | 4 +-- spec/system/warn_spec.rb | 8 ++--- 8 files changed, 64 insertions(+), 57 deletions(-) diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb index 0924e47..311fe0a 100644 --- a/spec/spec_helper_system.rb +++ b/spec/spec_helper_system.rb @@ -23,4 +23,11 @@ RSpec.configure do |c| puppet_module_install(:source => proj_root, :module_name => 'concat') shell('puppet module install puppetlabs-stdlib') end + + c.before(:all) do + shell('mkdir -p /tmp/concat') + end + c.after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end end diff --git a/spec/system/concat_spec.rb b/spec/system/concat_spec.rb index 55c8e3b..943de7e 100644 --- a/spec/system/concat_spec.rb +++ b/spec/system/concat_spec.rb @@ -29,25 +29,25 @@ describe 'basic concat test' do #it { should be_grouped_into 'root' } it { should be_mode 755 } end - describe file('/var/lib/puppet/concat/_tmp_file') do + describe file('/var/lib/puppet/concat/_tmp_concat_file') do it { should be_directory } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 750 } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments') do it { should be_directory } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 750 } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments.concat') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments.concat') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 640 } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments.concat.out') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments.concat.out') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } @@ -57,20 +57,20 @@ describe 'basic concat test' do context 'owner/group root' do pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': owner => 'root', group => 'root', mode => '0644', } concat::fragment { '1': - target => '/tmp/file', + target => '/tmp/concat/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/file', + target => '/tmp/concat/file', content => '2', order => '02', } @@ -78,7 +78,7 @@ describe 'basic concat test' do it_behaves_like 'successfully_applied', pp - describe file('/tmp/file') do + describe file('/tmp/concat/file') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } @@ -86,13 +86,13 @@ describe 'basic concat test' do it { should contain '1' } it { should contain '2' } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments/01_1') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/01_1') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 640 } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments/02_2') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/02_2') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } @@ -107,20 +107,20 @@ describe 'basic concat test' do end pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': owner => 'bob', group => 'bob', mode => '0644', } concat::fragment { '1': - target => '/tmp/file', + target => '/tmp/concat/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/file', + target => '/tmp/concat/file', content => '2', order => '02', } @@ -128,7 +128,7 @@ describe 'basic concat test' do it_behaves_like 'successfully_applied', pp - describe file('/tmp/file') do + describe file('/tmp/concat/file') do it { should be_file } it { should be_owned_by 'bob' } it { should be_grouped_into 'bob' } @@ -136,14 +136,14 @@ describe 'basic concat test' do it { should contain '1' } it { should contain '2' } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments/01_1') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/01_1') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 640 } it { should contain '1' } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments/02_2') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/02_2') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } diff --git a/spec/system/deprecation_warnings_spec.rb b/spec/system/deprecation_warnings_spec.rb index 29fcfb2..58e1e76 100644 --- a/spec/system/deprecation_warnings_spec.rb +++ b/spec/system/deprecation_warnings_spec.rb @@ -14,11 +14,11 @@ describe 'deprecation warnings' do context 'concat gnu parameter' do pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': gnu => 'foo', } concat::fragment { 'foo': - target => '/tmp/file', + target => '/tmp/concat/file', } " w = 'The $gnu parameter to concat is deprecated and has no effect' @@ -28,9 +28,9 @@ describe 'deprecation warnings' do context 'concat::fragment mode parameter' do pp=" - concat { '/tmp/file': } + concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/file', + target => '/tmp/concat/file', mode => 'bar', } " @@ -41,9 +41,9 @@ describe 'deprecation warnings' do context 'concat::fragment owner parameter' do pp=" - concat { '/tmp/file': } + concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/file', + target => '/tmp/concat/file', owner => 'bar', } " @@ -54,9 +54,9 @@ describe 'deprecation warnings' do context 'concat::fragment group parameter' do pp=" - concat { '/tmp/file': } + concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/file', + target => '/tmp/concat/file', group => 'bar', } " @@ -67,9 +67,9 @@ describe 'deprecation warnings' do context 'concat::fragment backup parameter' do pp=" - concat { '/tmp/file': } + concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/file', + target => '/tmp/concat/file', backup => 'bar', } " diff --git a/spec/system/empty_spec.rb b/spec/system/empty_spec.rb index 83dae01..67d968e 100644 --- a/spec/system/empty_spec.rb +++ b/spec/system/empty_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_system' describe 'basic concat test' do context 'should run successfully' do pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': owner => root, group => root, mode => '0644', @@ -19,7 +19,7 @@ describe 'basic concat test' do its(:exit_code) { should be_zero } end - describe file('/tmp/file') do + describe file('/tmp/concat/file') do it { should be_file } it { should_not contain '1\n2' } end diff --git a/spec/system/fragment_list_source_spec.rb b/spec/system/fragment_list_source_spec.rb index ebfe633..5716ef7 100644 --- a/spec/system/fragment_list_source_spec.rb +++ b/spec/system/fragment_list_source_spec.rb @@ -5,40 +5,40 @@ describe 'concat::fragment source lists ' do file1_contents="file1 contents" file2_contents="file2 contents" before(:all) do - shell("/bin/echo '#{file1_contents}' > /tmp/file1") - shell("/bin/echo '#{file2_contents}' > /tmp/file2") + shell("/bin/echo '#{file1_contents}' > /tmp/concat/file1") + shell("/bin/echo '#{file2_contents}' > /tmp/concat/file2") end pp=" - concat { '/tmp/result_file1': + concat { '/tmp/concat/result_file1': owner => root, group => root, mode => '0644', } - concat { '/tmp/result_file2': + concat { '/tmp/concat/result_file2': owner => root, group => root, mode => '0644', } - concat { '/tmp/result_file3': + concat { '/tmp/concat/result_file3': owner => root, group => root, mode => '0644', } concat::fragment { '1': - target => '/tmp/result_file1', - source => [ '/tmp/file1', '/tmp/file2' ], + target => '/tmp/concat/result_file1', + source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], order => '01', } concat::fragment { '2': - target => '/tmp/result_file2', - source => [ '/tmp/file2', '/tmp/file1' ], + target => '/tmp/concat/result_file2', + source => [ '/tmp/concat/file2', '/tmp/concat/file1' ], order => '01', } concat::fragment { '3': - target => '/tmp/result_file3', - source => [ '/tmp/file1', '/tmp/file2' ], + target => '/tmp/concat/result_file3', + source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], order => '01', } " @@ -49,17 +49,17 @@ describe 'concat::fragment source lists ' do its(:stderr) { should be_empty } its(:exit_code) { should be_zero } end - describe file('/tmp/result_file1') do + describe file('/tmp/concat/result_file1') do it { should be_file } it { should contain file1_contents } it { should_not contain file2_contents } end - describe file('/tmp/result_file2') do + describe file('/tmp/concat/result_file2') do it { should be_file } it { should contain file2_contents } it { should_not contain file1_contents } end - describe file('/tmp/result_file3') do + describe file('/tmp/concat/result_file3') do it { should be_file } it { should contain file1_contents } it { should_not contain file2_contents } @@ -68,18 +68,18 @@ describe 'concat::fragment source lists ' do context 'should fail if no match on source.' do before(:all) do - shell("/bin/rm /tmp/fail_no_source /tmp/nofilehere /tmp/nothereeither") + shell("/bin/rm /tmp/concat/fail_no_source /tmp/concat/nofilehere /tmp/concat/nothereeither") end pp=" - concat { '/tmp/fail_no_source': + concat { '/tmp/concat/fail_no_source': owner => root, group => root, mode => '0644', } concat::fragment { '1': - target => '/tmp/fail_no_source', - source => [ '/tmp/nofilehere', '/tmp/nothereeither' ], + target => '/tmp/concat/fail_no_source', + source => [ '/tmp/concat/nofilehere', '/tmp/concat/nothereeither' ], order => '01', } " @@ -88,7 +88,7 @@ describe 'concat::fragment source lists ' do its(:exit_code) { should_not == 1 } its(:refresh) { should be_nil } end - describe file('/tmp/fail_no_source') do + describe file('/tmp/concat/fail_no_source') do #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack. it { should_not be_file } it { should_not be_directory } diff --git a/spec/system/replace_spec.rb b/spec/system/replace_spec.rb index 7f11e5f..4844087 100644 --- a/spec/system/replace_spec.rb +++ b/spec/system/replace_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper_system' describe 'file should not replace' do - shell('echo "file exists" >> /tmp/file') + shell('echo "file exists" >> /tmp/concat/file') context 'should fail' do pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': owner => root, group => root, mode => '0644', @@ -13,13 +13,13 @@ describe 'file should not replace' do } concat::fragment { '1': - target => '/tmp/file', + target => '/tmp/concat/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/file', + target => '/tmp/concat/file', content => '2', order => '02', } diff --git a/spec/system/symbolic_name_spec.rb b/spec/system/symbolic_name_spec.rb index 2b687c0..239aa80 100644 --- a/spec/system/symbolic_name_spec.rb +++ b/spec/system/symbolic_name_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_system' describe 'symbolic name' do pp=" concat { 'not_abs_path': - path => '/tmp/file', + path => '/tmp/concat/file', } concat::fragment { '1': @@ -27,7 +27,7 @@ describe 'symbolic name' do its(:exit_code) { should be_zero } end - describe file('/tmp/file') do + describe file('/tmp/concat/file') do it { should be_file } it { should contain '1' } it { should contain '2' } diff --git a/spec/system/warn_spec.rb b/spec/system/warn_spec.rb index 872058b..d5052ba 100644 --- a/spec/system/warn_spec.rb +++ b/spec/system/warn_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_system' describe 'basic concat test' do context 'should run successfully' do pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': owner => root, group => root, mode => '0644', @@ -11,13 +11,13 @@ describe 'basic concat test' do } concat::fragment { '1': - target => '/tmp/file', + target => '/tmp/concat/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/file', + target => '/tmp/concat/file', content => '2', order => '02', } @@ -31,7 +31,7 @@ describe 'basic concat test' do its(:exit_code) { should be_zero } end - describe file('/tmp/file') do + describe file('/tmp/concat/file') do it { should be_file } it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } it { should contain '1' }