3 describe 'concat::fragment', :type => :define do
5 shared_examples 'fragment' do |title, params|
6 params = {} if params.nil?
15 let(:params) { params }
16 let(:pre_condition) do
17 "concat{ '#{p[:target]}': }"
21 should contain_concat(p[:target])
22 should contain_concat_file(p[:target])
23 should contain_concat_fragment(title)
28 ['0', '1', 'a', 'z'].each do |title|
29 it_behaves_like 'fragment', title, {
30 :target => '/etc/motd',
31 :content => "content for #{title}"
36 context 'target =>' do
37 ['./etc/motd', 'etc/motd', 'motd_header'].each do |target|
39 it_behaves_like 'fragment', target, {
40 :target => '/etc/motd',
41 :content => "content for #{target}"
47 let(:title) { 'motd_header' }
48 let(:params) {{ :target => false }}
51 expect { catalogue }.to raise_error(Puppet::Error, /parameter 'target' expects a .*String.*/)
56 context 'content =>' do
57 ['', 'ashp is our hero'].each do |content|
59 it_behaves_like 'fragment', 'motd_header', {
61 :target => '/etc/motd',
67 let(:title) { 'motd_header' }
68 let(:params) {{ :content => false, :target => '/etc/motd' }}
71 expect { catalogue }.to raise_error(Puppet::Error, /parameter 'content' expects a .*String.*/ )
76 context 'source =>' do
77 ['', '/foo/bar', ['/foo/bar', '/foo/baz']].each do |source|
79 it_behaves_like 'fragment', 'motd_header', {
81 :target => '/etc/motd',
87 let(:title) { 'motd_header' }
88 let(:params) {{ :source => false, :target => '/etc/motd' }}
91 expect { catalogue }.to raise_error(Puppet::Error, /parameter 'source' expects a .*String.*Array.*/)
97 ['', '42', 'a', 'z'].each do |order|
99 it_behaves_like 'fragment', 'motd_header', {
101 :target => '/etc/motd',
107 let(:title) { 'motd_header' }
108 let(:params) {{ :order => false, :target => '/etc/motd' }}
111 expect { catalogue }.to raise_error(Puppet::Error, /Evaluation Error.*expects.*Boolean.*/)
116 let(:title) { 'motd_header' }
117 let(:params) {{ :order => '123:456', :target => '/etc/motd' }}
120 expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/)
124 let(:title) { 'motd_header' }
125 let(:params) {{ :order => '123/456', :target => '/etc/motd' }}
128 expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/)
131 context '123\n456' do
132 let(:title) { 'motd_header' }
133 let(:params) {{ :order => "123\n456", :target => '/etc/motd' }}
136 expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/)
141 context 'more than one content source' do
142 context 'source and content' do
143 let(:title) { 'motd_header' }
146 :target => '/etc/motd',
153 expect { catalogue }.to raise_error(Puppet::Error, /Can\'t use \'source\' and \'content\' at the same time/m)
156 end # more than one content source