3 describe 'concat::fragment', :type => :define do
5 shared_examples 'fragment' do |title, params|
6 params = {} if params.nil?
18 let(:params) { params }
19 let(:pre_condition) do
20 "concat{ '#{p[:target]}': }"
24 should contain_concat(p[:target])
25 should contain_concat_file(p[:target])
26 should contain_concat_fragment(title)
31 ['0', '1', 'a', 'z'].each do |title|
32 it_behaves_like 'fragment', title, {
33 :target => '/etc/motd',
34 :content => "content for #{title}"
39 context 'target =>' do
40 ['./etc/motd', 'etc/motd', 'motd_header'].each do |target|
42 it_behaves_like 'fragment', target, {
43 :target => '/etc/motd',
44 :content => "content for #{target}"
50 let(:title) { 'motd_header' }
51 let(:params) {{ :target => false }}
54 expect { catalogue }.to raise_error(Puppet::Error, /is not a string/)
59 context 'content =>' do
60 ['', 'ashp is our hero'].each do |content|
62 it_behaves_like 'fragment', 'motd_header', {
64 :target => '/etc/motd',
70 let(:title) { 'motd_header' }
71 let(:params) {{ :content => false, :target => '/etc/motd' }}
74 expect { catalogue }.to raise_error(Puppet::Error, /is not a string/)
79 context 'source =>' do
80 ['', '/foo/bar', ['/foo/bar', '/foo/baz']].each do |source|
82 it_behaves_like 'fragment', 'motd_header', {
84 :target => '/etc/motd',
90 let(:title) { 'motd_header' }
91 let(:params) {{ :source => false, :target => '/etc/motd' }}
94 expect { catalogue }.to raise_error(Puppet::Error, /is not a string or an Array/)
99 context 'more than one content source' do
100 context 'source and content' do
101 let(:title) { 'motd_header' }
104 :target => '/etc/motd',
111 expect { catalogue }.to raise_error(Puppet::Error, /Can't use 'source' and 'content' at the same time/)
114 end # more than one content source