1
require 'spec_helper_acceptance'
3
describe 'replacement of' do
4
basedir = default.tmpdir('concat')
6
context 'should not succeed' do
12
file { '#{basedir}/file':
13
content => "file exists\n"
19
concat { '#{basedir}/file':
23
concat::fragment { '1':
24
target => '#{basedir}/file',
28
concat::fragment { '2':
29
target => '#{basedir}/file',
34
it 'applies the manifest twice with no stderr' do
35
apply_manifest(pp, :catch_failures => true)
36
apply_manifest(pp, :catch_changes => true)
39
describe file("#{basedir}/file") do
41
it { should contain 'file exists' }
42
it { should_not contain '1' }
43
it { should_not contain '2' }
47
context 'should succeed' do
53
file { '#{basedir}/file':
54
content => "file exists\n"
60
concat { '#{basedir}/file':
64
concat::fragment { '1':
65
target => '#{basedir}/file',
69
concat::fragment { '2':
70
target => '#{basedir}/file',
75
it 'applies the manifest twice with no stderr' do
76
apply_manifest(pp, :catch_failures => true)
77
apply_manifest(pp, :catch_changes => true)
80
describe file("#{basedir}/file") do
82
it { should_not contain 'file exists' }
83
it { should contain '1' }
84
it { should contain '2' }
89
context 'symlink', :unless => (fact("osfamily") == "windows") do
90
context 'should not succeed' do
91
# XXX the core puppet file type will replace a symlink with a plain file
92
# when using ensure => present and source => ... but it will not when using
93
# ensure => present and content => ...; this is somewhat confusing behavior
99
file { '#{basedir}/file':
101
target => '#{basedir}/dangling',
108
concat { '#{basedir}/file':
112
concat::fragment { '1':
113
target => '#{basedir}/file',
117
concat::fragment { '2':
118
target => '#{basedir}/file',
123
it 'applies the manifest twice with no stderr' do
124
apply_manifest(pp, :catch_failures => true)
125
apply_manifest(pp, :catch_changes => true)
128
# XXX specinfra doesn't support be_linked_to on AIX
129
describe file("#{basedir}/file"), :unless => (fact("osfamily") == "AIX") do
130
it { should be_linked_to "#{basedir}/dangling" }
133
describe file("#{basedir}/dangling") do
134
# XXX serverspec does not have a matcher for 'exists'
135
it { should_not be_file }
136
it { should_not be_directory }
140
context 'should succeed' do
141
# XXX the core puppet file type will replace a symlink with a plain file
142
# when using ensure => present and source => ... but it will not when using
143
# ensure => present and content => ...; this is somewhat confusing behavior
149
file { '#{basedir}/file':
151
target => '#{basedir}/dangling',
158
concat { '#{basedir}/file':
162
concat::fragment { '1':
163
target => '#{basedir}/file',
167
concat::fragment { '2':
168
target => '#{basedir}/file',
173
it 'applies the manifest twice with no stderr' do
174
apply_manifest(pp, :catch_failures => true)
175
apply_manifest(pp, :catch_changes => true)
178
describe file("#{basedir}/file") do
179
it { should be_file }
180
it { should contain '1' }
181
it { should contain '2' }
186
context 'directory' do
187
context 'should not succeed' do
193
file { '#{basedir}/file':
200
concat { '#{basedir}/file': }
202
concat::fragment { '1':
203
target => '#{basedir}/file',
207
concat::fragment { '2':
208
target => '#{basedir}/file',
213
it 'applies the manifest twice with stderr for changing to file' do
214
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/)
215
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/)
218
describe file("#{basedir}/file") do
219
it { should be_directory }
223
# XXX concat's force param currently enables the creation of empty files
224
# when there are no fragments, and the replace param will only replace
225
# files and symlinks, not directories. The semantics either need to be
226
# changed, extended, or a new param introduced to control directory
228
context 'should succeed', :pending => 'not yet implemented' do
230
concat { '#{basedir}/file':
234
concat::fragment { '1':
235
target => '#{basedir}/file',
239
concat::fragment { '2':
240
target => '#{basedir}/file',
245
it 'applies the manifest twice with no stderr' do
246
apply_manifest(pp, :catch_failures => true)
247
apply_manifest(pp, :catch_changes => true)
250
describe file("#{basedir}/file") do
251
it { should be_file }
252
it { should contain '1' }