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
42 should match 'file exists'
49 context 'should succeed' do
55 file { '#{basedir}/file':
56 content => "file exists\n"
62 concat { '#{basedir}/file':
66 concat::fragment { '1':
67 target => '#{basedir}/file',
71 concat::fragment { '2':
72 target => '#{basedir}/file',
77 it 'applies the manifest twice with no stderr' do
78 apply_manifest(pp, :catch_failures => true)
79 apply_manifest(pp, :catch_changes => true)
82 describe file("#{basedir}/file") do
85 should_not match 'file exists'
93 context 'symlink', :unless => (fact("osfamily") == "windows") do
94 context 'should not succeed' do
95 # XXX the core puppet file type will replace a symlink with a plain file
96 # when using ensure => present and source => ... but it will not when using
97 # ensure => present and content => ...; this is somewhat confusing behavior
103 file { '#{basedir}/file':
105 target => '#{basedir}/dangling',
112 concat { '#{basedir}/file':
116 concat::fragment { '1':
117 target => '#{basedir}/file',
121 concat::fragment { '2':
122 target => '#{basedir}/file',
127 it 'applies the manifest twice with no stderr' do
128 apply_manifest(pp, :catch_failures => true)
129 apply_manifest(pp, :catch_changes => true)
132 # XXX specinfra doesn't support be_linked_to on AIX
133 describe file("#{basedir}/file"), :unless => (fact("osfamily") == "AIX" or fact("osfamily") == "windows") do
134 it { should be_linked_to "#{basedir}/dangling" }
137 describe file("#{basedir}/dangling") do
138 # XXX serverspec does not have a matcher for 'exists'
139 it { should_not be_file }
140 it { should_not be_directory }
144 context 'should succeed' do
145 # XXX the core puppet file type will replace a symlink with a plain file
146 # when using ensure => present and source => ... but it will not when using
147 # ensure => present and content => ...; this is somewhat confusing behavior
153 file { '#{basedir}/file':
155 target => '#{basedir}/dangling',
162 concat { '#{basedir}/file':
166 concat::fragment { '1':
167 target => '#{basedir}/file',
171 concat::fragment { '2':
172 target => '#{basedir}/file',
177 it 'applies the manifest twice with no stderr' do
178 apply_manifest(pp, :catch_failures => true)
179 apply_manifest(pp, :catch_changes => true)
182 describe file("#{basedir}/file") do
183 it { should be_file }
192 context 'directory' do
193 context 'should not succeed' do
199 file { '#{basedir}/file':
206 concat { '#{basedir}/file': }
208 concat::fragment { '1':
209 target => '#{basedir}/file',
213 concat::fragment { '2':
214 target => '#{basedir}/file',
219 it 'applies the manifest twice with stderr for changing to file' do
220 expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from '?directory'? to '?file'? failed/)
221 expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from '?directory'? to '?file'? failed/)
224 describe file("#{basedir}/file") do
225 it { should be_directory }
230 # when there are no fragments, and the replace param will only replace
231 # files and symlinks, not directories. The semantics either need to be
232 # changed, extended, or a new param introduced to control directory
234 context 'should succeed', :pending => 'not yet implemented' do
236 concat { '#{basedir}/file':
239 concat::fragment { '1':
240 target => '#{basedir}/file',
244 concat::fragment { '2':
245 target => '#{basedir}/file',
250 it 'applies the manifest twice with no stderr' do
251 apply_manifest(pp, :catch_failures => true)
252 apply_manifest(pp, :catch_changes => true)
255 describe file("#{basedir}/file") do
256 it { should be_file }
257 its(:content) { should match '1' }