]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/concat/spec/acceptance/fragments_are_always_replaced_spec.rb
upgrade to concat 2.0.0
[dsa-puppet.git] / 3rdparty / modules / concat / spec / acceptance / fragments_are_always_replaced_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'concat::fragment replace' do
4   basedir = default.tmpdir('concat')
5
6   context 'should create fragment files' do
7     before(:all) do
8       pp = <<-EOS
9         file { '#{basedir}':
10           ensure => directory,
11         }
12       EOS
13       apply_manifest(pp)
14     end
15
16     pp1 = <<-EOS
17       concat { '#{basedir}/foo': }
18
19       concat::fragment { '1':
20         target  => '#{basedir}/foo',
21         content => 'caller has replace unset run 1',
22       }
23     EOS
24     pp2 = <<-EOS
25       concat { '#{basedir}/foo': }
26
27       concat::fragment { '1':
28         target  => '#{basedir}/foo',
29         content => 'caller has replace unset run 2',
30       }
31     EOS
32
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)
38     end
39
40     describe file("#{basedir}/foo") do
41       it { should be_file }
42       its(:content) {
43         should_not match 'caller has replace unset run 1'
44         should match 'caller has replace unset run 2'
45       }
46     end
47   end # should create fragment files
48
49   context 'should replace its own fragment files when caller has File { replace=>true } set' do
50     before(:all) do
51       pp = <<-EOS
52         file { '#{basedir}':
53           ensure => directory,
54         }
55       EOS
56       apply_manifest(pp)
57     end
58
59     pp1 = <<-EOS
60       File { replace=>true }
61       concat { '#{basedir}/foo': }
62
63       concat::fragment { '1':
64         target  => '#{basedir}/foo',
65         content => 'caller has replace true set run 1',
66       }
67     EOS
68     pp2 = <<-EOS
69       File { replace=>true }
70       concat { '#{basedir}/foo': }
71
72       concat::fragment { '1':
73         target  => '#{basedir}/foo',
74         content => 'caller has replace true set run 2',
75       }
76     EOS
77
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)
83     end
84
85     describe file("#{basedir}/foo") do
86       it { should be_file }
87       its(:content) {
88         should_not match 'caller has replace true set run 1'
89         should match 'caller has replace true set run 2'
90       }
91     end
92   end # should replace its own fragment files when caller has File(replace=>true) set
93
94   context 'should replace its own fragment files even when caller has File { replace=>false } set' do
95     before(:all) do
96       pp = <<-EOS
97         file { '#{basedir}':
98           ensure => directory,
99         }
100       EOS
101       apply_manifest(pp)
102     end
103
104     pp1 = <<-EOS
105       File { replace=>false }
106       concat { '#{basedir}/foo': }
107
108       concat::fragment { '1':
109         target  => '#{basedir}/foo',
110         content => 'caller has replace false set run 1',
111       }
112     EOS
113     pp2 = <<-EOS
114       File { replace=>false }
115       concat { '#{basedir}/foo': }
116
117       concat::fragment { '1':
118         target  => '#{basedir}/foo',
119         content => 'caller has replace false set run 2',
120       }
121     EOS
122
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)
128     end
129
130     describe file("#{basedir}/foo") do
131       it { should be_file }
132       its(:content) {
133         should_not match 'caller has replace false set run 1'
134         should match 'caller has replace false set run 2'
135       }
136     end
137   end # should replace its own fragment files even when caller has File(replace=>false) set
138
139 end