1 require 'spec_helper_acceptance'
3 describe 'concat order' do
4 basedir = default.tmpdir('concat')
7 shared_examples 'sortby' do |order_by, match_output|
9 concat { '#{basedir}/foo':
10 order => '#{order_by}'
12 concat::fragment { '1':
13 target => '#{basedir}/foo',
17 concat::fragment { '2':
18 target => '#{basedir}/foo',
22 concat::fragment { '10':
23 target => '#{basedir}/foo',
24 content => 'string10',
28 it 'applies the manifest twice with no stderr' do
29 apply_manifest(pp, :catch_failures => true)
30 apply_manifest(pp, :catch_changes => true)
33 describe file("#{basedir}/foo") do
35 its(:content) { should match match_output }
40 it_behaves_like 'sortby', 'alpha', /string1string10string2/
44 it_behaves_like 'sortby', 'numeric', /string1string2string10/
49 describe 'concat::fragment order' do
50 basedir = default.tmpdir('concat')
52 context '=> reverse order' do
53 shared_examples 'order_by' do |order_by, match_output|
55 concat { '#{basedir}/foo':
56 order => '#{order_by}'
58 concat::fragment { '1':
59 target => '#{basedir}/foo',
63 concat::fragment { '2':
64 target => '#{basedir}/foo',
68 concat::fragment { '3':
69 target => '#{basedir}/foo',
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}/foo") do
82 its(:content) { should match match_output }
86 it_should_behave_like 'order_by', 'alpha', /string3string2string1/
89 it_should_behave_like 'order_by', 'numeric', /string3string2string1/
93 context '=> normal order' do
95 concat { '#{basedir}/foo': }
96 concat::fragment { '1':
97 target => '#{basedir}/foo',
101 concat::fragment { '2':
102 target => '#{basedir}/foo',
103 content => 'string2',
106 concat::fragment { '3':
107 target => '#{basedir}/foo',
108 content => 'string3',
113 it 'applies the manifest twice with no stderr' do
114 apply_manifest(pp, :catch_failures => true)
115 apply_manifest(pp, :catch_changes => true)
118 describe file("#{basedir}/foo") do
119 it { should be_file }
120 its(:content) { should match /string1string2string3/ }
123 end # concat::fragment order