X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fconcat%2Fspec%2Facceptance%2Fwarn_header_spec.rb;h=84894b4825b7db8bd12a07d6b949cee5088b43c3;hp=b73414e34052b47f163980b464beb98dbc581a5d;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/concat/spec/acceptance/warn_header_spec.rb b/3rdparty/modules/concat/spec/acceptance/warn_header_spec.rb index b73414e34..84894b482 100644 --- a/3rdparty/modules/concat/spec/acceptance/warn_header_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/warn_header_spec.rb @@ -1,104 +1,84 @@ require 'spec_helper_acceptance' -describe 'concat warn =>' do - basedir = default.tmpdir('concat') - context 'true should enable default warning message' do - pp = <<-EOS - concat { '#{basedir}/file': +describe 'concat warn_header =>' do + before(:all) do + @basedir = setup_test_directory + end + + describe 'applies the manifest twice with no stderr' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': warn => true, } concat::fragment { '1': - target => '#{basedir}/file', + target => '#{@basedir}/file', content => '1', order => '01', } concat::fragment { '2': - target => '#{basedir}/file', + target => '#{@basedir}/file', content => '2', order => '02', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match /# This file is managed by Puppet\. DO NOT EDIT\./ - should match /1/ - should match /2/ - } - end - end - context 'false should not enable default warning message' do - pp = <<-EOS - concat { '#{basedir}/file': + concat { '#{@basedir}/file2': warn => false, } - concat::fragment { '1': - target => '#{basedir}/file', + concat::fragment { 'file2_1': + target => '#{@basedir}/file2', content => '1', order => '01', } - concat::fragment { '2': - target => '#{basedir}/file', + concat::fragment { 'file2_2': + target => '#{@basedir}/file2', content => '2', order => '02', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should_not match /# This file is managed by Puppet\. DO NOT EDIT\./ - should match /1/ - should match /2/ - } - end - end - context '# foo should overide default warning message' do - pp = <<-EOS - concat { '#{basedir}/file': + concat { '#{@basedir}/file3': warn => "# foo\n", } - concat::fragment { '1': - target => '#{basedir}/file', + concat::fragment { 'file3_1': + target => '#{@basedir}/file3', content => '1', order => '01', } - concat::fragment { '2': - target => '#{basedir}/file', + concat::fragment { 'file3_2': + target => '#{@basedir}/file3', content => '2', order => '02', } - EOS - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + MANIFEST end - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match /# foo/ - should match /1/ - should match /2/ - } + it 'when true should enable default warning message' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match %r{# This file is managed by Puppet\. DO NOT EDIT\.} + expect(file("#{@basedir}/file").content).to match %r{1} + expect(file("#{@basedir}/file").content).to match %r{2} + end + + it 'when false should not enable default warning message' do + expect(file("#{@basedir}/file2")).to be_file + expect(file("#{@basedir}/file2").content).not_to match %r{# This file is managed by Puppet\. DO NOT EDIT\.} + expect(file("#{@basedir}/file2").content).to match %r{1} + expect(file("#{@basedir}/file2").content).to match %r{2} + end + + it 'when foo should overide default warning message' do + expect(file("#{@basedir}/file3")).to be_file + expect(file("#{@basedir}/file3").content).to match %r{# foo} + expect(file("#{@basedir}/file3").content).to match %r{1} + expect(file("#{@basedir}/file3").content).to match %r{2} end end end