1 require 'spec_helper_acceptance'
3 describe 'concat::fragment replace' do
4 basedir = default.tmpdir('concat')
6 context 'should create fragment files' do
17 concat { '#{basedir}/foo': }
19 concat::fragment { '1':
20 target => '#{basedir}/foo',
21 content => 'caller has replace unset run 1',
25 concat { '#{basedir}/foo': }
27 concat::fragment { '1':
28 target => '#{basedir}/foo',
29 content => 'caller has replace unset run 2',
33 it 'applies the manifest twice with no stderr' do
34 apply_manifest(pp1, :catch_failures => true)
35 apply_manifest(pp1, :catch_changes => true)
36 apply_manifest(pp2, :catch_failures => true)
37 apply_manifest(pp2, :catch_changes => true)
40 describe file("#{basedir}/foo") do
43 should_not match 'caller has replace unset run 1'
44 should match 'caller has replace unset run 2'
47 end # should create fragment files
49 context 'should replace its own fragment files when caller has File { replace=>true } set' do
60 File { replace=>true }
61 concat { '#{basedir}/foo': }
63 concat::fragment { '1':
64 target => '#{basedir}/foo',
65 content => 'caller has replace true set run 1',
69 File { replace=>true }
70 concat { '#{basedir}/foo': }
72 concat::fragment { '1':
73 target => '#{basedir}/foo',
74 content => 'caller has replace true set run 2',
78 it 'applies the manifest twice with no stderr' do
79 apply_manifest(pp1, :catch_failures => true)
80 apply_manifest(pp1, :catch_changes => true)
81 apply_manifest(pp2, :catch_failures => true)
82 apply_manifest(pp2, :catch_changes => true)
85 describe file("#{basedir}/foo") do
88 should_not match 'caller has replace true set run 1'
89 should match 'caller has replace true set run 2'
92 end # should replace its own fragment files when caller has File(replace=>true) set
94 context 'should replace its own fragment files even when caller has File { replace=>false } set' do
105 File { replace=>false }
106 concat { '#{basedir}/foo': }
108 concat::fragment { '1':
109 target => '#{basedir}/foo',
110 content => 'caller has replace false set run 1',
114 File { replace=>false }
115 concat { '#{basedir}/foo': }
117 concat::fragment { '1':
118 target => '#{basedir}/foo',
119 content => 'caller has replace false set run 2',
123 it 'applies the manifest twice with no stderr' do
124 apply_manifest(pp1, :catch_failures => true)
125 apply_manifest(pp1, :catch_changes => true)
126 apply_manifest(pp2, :catch_failures => true)
127 apply_manifest(pp2, :catch_changes => true)
130 describe file("#{basedir}/foo") do
131 it { should be_file }
133 should_not match 'caller has replace false set run 1'
134 should match 'caller has replace false set run 2'
137 end # should replace its own fragment files even when caller has File(replace=>false) set