X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fconcat%2Fspec%2Facceptance%2Fbackup_spec.rb;h=80a98794068622ca9a52f987b418b62a0c323a5a;hp=0a737a55640844e2d63f4177dd662635923a556c;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/concat/spec/acceptance/backup_spec.rb b/3rdparty/modules/concat/spec/acceptance/backup_spec.rb index 0a737a556..80a987940 100644 --- a/3rdparty/modules/concat/spec/acceptance/backup_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/backup_spec.rb @@ -1,115 +1,77 @@ require 'spec_helper_acceptance' describe 'concat backup parameter' do - basedir = default.tmpdir('concat') - context '=> puppet' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, + before(:all) do + @basedir = setup_test_directory + end + + describe 'when puppet' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + backup => 'puppet', } - file { '#{basedir}/file': - content => "old contents\n", + concat::fragment { 'new file': + target => '#{@basedir}/file', + content => 'new contents', } - EOS - apply_manifest(pp) + MANIFEST end - pp = <<-EOS - concat { '#{basedir}/file': - backup => 'puppet', - } - concat::fragment { 'new file': - target => '#{basedir}/file', - content => 'new contents', - } - EOS it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Filebucketed #{basedir}\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) - end - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match /new contents/ } + expect(apply_manifest(pp, catch_failures: true, debug: true).stdout).to match(%r{Filebucketed.*to puppet with sum.*}) + apply_manifest(pp, catch_changes: true) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match %r{new contents} end end - context '=> .backup' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - content => "old contents\n", - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': + describe 'when .backup' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': backup => '.backup', } concat::fragment { 'new file': - target => '#{basedir}/file', - content => 'new contents', + target => '#{@basedir}/file', + content => 'backup extension', } - EOS + MANIFEST + end # XXX Puppet doesn't mention anything about filebucketing with a given # extension like .backup - it 'applies the manifest twice 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 /new contents/ } - end - describe file("#{basedir}/file.backup") do - it { should be_file } - its(:content) { should match /old contents/ } + it 'applies the manifest twice no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match %r{backup extension} + expect(file("#{@basedir}/file.backup")).to be_file + expect(file("#{@basedir}/file.backup").content).to match %r{new contents} end end # XXX The backup parameter uses validate_string() and thus can't be the # boolean false value, but the string 'false' has the same effect in Puppet 3 - context "=> 'false'" do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - content => "old contents\n", - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': + describe "when 'false'" do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': backup => '.backup', } concat::fragment { 'new file': - target => '#{basedir}/file', + target => '#{@basedir}/file', content => 'new contents', } - EOS + MANIFEST + end it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to_not match(/Filebucketed/) + apply_manifest(pp, catch_failures: true) do |r| + expect(r.stdout).not_to match(%r{Filebucketed}) end - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match /new contents/ } + apply_manifest(pp, catch_changes: true) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match %r{new contents} end end end