diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb index 1989f44..1d3a5df 100644 --- a/spec/acceptance/backup_spec.rb +++ b/spec/acceptance/backup_spec.rb @@ -1,115 +1,115 @@ 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, } file { '#{basedir}/file': content => "old contents\n", } EOS apply_manifest(pp) 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/) # sum is for file contents of 'old contents' end apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do it { should be_file } - it { should contain 'new contents' } + its(:content) { should match /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': backup => '.backup', } concat::fragment { 'new file': target => '#{basedir}/file', content => 'new contents', } EOS # 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 } - it { should contain 'new contents' } + its(:content) { should match /new contents/ } end describe file("#{basedir}/file.backup") do it { should be_file } - it { should contain 'old contents' } + its(:content) { should match /old 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': backup => '.backup', } concat::fragment { 'new file': target => '#{basedir}/file', content => 'new contents', } EOS 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/) end apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do it { should be_file } - it { should contain 'new contents' } + its(:content) { should match /new contents/ } end end end diff --git a/spec/acceptance/specinfra_stubs.rb b/spec/acceptance/specinfra_stubs.rb index d42e1c0..bae85ef 100644 --- a/spec/acceptance/specinfra_stubs.rb +++ b/spec/acceptance/specinfra_stubs.rb @@ -1,18 +1,19 @@ class Specinfra::Command::Windows::Base::File < Specinfra::Command::Windows::Base class << self def check_is_owned_by(file, owner) Backend::PowerShell::Command.new do - exec "((gci '#{file}').GetAccessControl().Owner -match '#{owner}').Length -gt 0" + exec "if((Get-Item '#{file}').GetAccessControl().Owner -match '#{owner}' + -or ((Get-Item '#{file}').GetAccessControl().Owner -match '#{owner}').Length -gt 0){ exit 0 } else { exit 1 }" end end end end class Specinfra::Command::Base::File < Specinfra::Command::Base class << self def get_content(file) "cat '#{file}' 2> /dev/null || echo -n" end end end diff --git a/spec/acceptance/warn_spec.rb b/spec/acceptance/warn_spec.rb index 7101f61..2788607 100644 --- a/spec/acceptance/warn_spec.rb +++ b/spec/acceptance/warn_spec.rb @@ -1,102 +1,104 @@ 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': warn => true, } concat::fragment { '1': target => '#{basedir}/file', content => '1', order => '01', } concat::fragment { '2': 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' + 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': warn => false, } concat::fragment { '1': target => '#{basedir}/file', content => '1', order => '01', } concat::fragment { '2': 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 } - it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' } - it { should contain '1' } - it { should contain '2' } + 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': warn => '# foo', } concat::fragment { '1': target => '#{basedir}/file', content => '1', order => '01', } concat::fragment { '2': 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 '# foo' - should match '1' - should match '2' + should match /# foo/ + should match /1/ + should match /2/ } end end end