2014-01-15 20:16:49 +01:00
|
|
|
require 'spec_helper_acceptance'
|
|
|
|
|
|
|
|
describe 'concat ensure_newline parameter' do
|
2014-02-28 00:50:18 +01:00
|
|
|
basedir = default.tmpdir('concat')
|
2014-01-15 20:16:49 +01:00
|
|
|
context '=> false' do
|
2014-09-11 01:06:17 +02:00
|
|
|
before(:all) do
|
|
|
|
pp = <<-EOS
|
|
|
|
file { '#{basedir}':
|
|
|
|
ensure => directory
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
|
|
|
|
apply_manifest(pp)
|
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
pp = <<-EOS
|
2014-02-27 23:52:53 +01:00
|
|
|
concat { '#{basedir}/file':
|
2014-01-15 20:16:49 +01:00
|
|
|
ensure_newline => false,
|
|
|
|
}
|
|
|
|
concat::fragment { '1':
|
2014-02-27 23:52:53 +01:00
|
|
|
target => '#{basedir}/file',
|
2014-01-15 20:16:49 +01:00
|
|
|
content => '1',
|
|
|
|
}
|
|
|
|
concat::fragment { '2':
|
2014-02-27 23:52:53 +01:00
|
|
|
target => '#{basedir}/file',
|
2014-01-15 20:16:49 +01:00
|
|
|
content => '2',
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
|
|
|
|
it 'applies the manifest twice with no stderr' do
|
2014-09-08 21:01:30 +02:00
|
|
|
apply_manifest(pp, :catch_failures => true)
|
|
|
|
apply_manifest(pp, :catch_changes => true)
|
2014-01-15 20:16:49 +01:00
|
|
|
end
|
|
|
|
|
2014-02-27 23:52:53 +01:00
|
|
|
describe file("#{basedir}/file") do
|
2014-01-15 20:16:49 +01:00
|
|
|
it { should be_file }
|
2015-02-09 23:42:34 +01:00
|
|
|
its(:content) { should match '12' }
|
2014-01-15 20:16:49 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context '=> true' do
|
|
|
|
pp = <<-EOS
|
2014-09-10 21:03:35 +02:00
|
|
|
concat { '#{basedir}/file':
|
2014-01-15 20:16:49 +01:00
|
|
|
ensure_newline => true,
|
|
|
|
}
|
|
|
|
concat::fragment { '1':
|
2014-09-10 21:03:35 +02:00
|
|
|
target => '#{basedir}/file',
|
2014-01-15 20:16:49 +01:00
|
|
|
content => '1',
|
|
|
|
}
|
|
|
|
concat::fragment { '2':
|
2014-09-10 21:03:35 +02:00
|
|
|
target => '#{basedir}/file',
|
2014-01-15 20:16:49 +01:00
|
|
|
content => '2',
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
|
|
|
|
it 'applies the manifest twice with no stderr' do
|
2014-09-08 21:01:30 +02:00
|
|
|
apply_manifest(pp, :catch_failures => true)
|
2015-02-09 23:42:34 +01:00
|
|
|
apply_manifest(pp, :catch_changes => true)
|
2014-01-15 20:16:49 +01:00
|
|
|
end
|
|
|
|
|
2014-09-11 01:06:17 +02:00
|
|
|
describe file("#{basedir}/file") do
|
2014-01-15 20:16:49 +01:00
|
|
|
it { should be_file }
|
2015-02-09 23:42:34 +01:00
|
|
|
its(:content) {
|
|
|
|
should match /1\n2\n/
|
2014-09-11 19:56:55 +02:00
|
|
|
}
|
2014-01-15 20:16:49 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|