Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / concat / spec / acceptance / fragment_order_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'concat::fragment order' do
4   before(:all) do
5     @basedir = setup_test_directory
6   end
7
8   describe 'with reverse order, alphabetical' do
9     let(:pp) do
10       <<-MANIFEST
11         concat { '#{@basedir}/foo':
12           order => 'alpha'
13         }
14         concat::fragment { '1':
15           target  => '#{@basedir}/foo',
16           content => 'string1',
17           order   => '15',
18         }
19         concat::fragment { '2':
20           target  => '#{@basedir}/foo',
21           content => 'string2',
22           # default order 10
23         }
24         concat::fragment { '3':
25           target  => '#{@basedir}/foo',
26           content => 'string3',
27           order   => '1',
28         }
29       MANIFEST
30     end
31
32     it 'idempotent, file matches' do
33       idempotent_apply(pp)
34       expect(file("#{@basedir}/foo")).to be_file
35       expect(file("#{@basedir}/foo").content).to match %r{string3string2string1}
36     end
37   end
38
39   describe 'with reverse order, numeric' do
40     let(:pp) do
41       <<-MANIFEST
42         concat { '#{@basedir}/foo':
43           order => 'numeric'
44         }
45         concat::fragment { '1':
46           target  => '#{@basedir}/foo',
47           content => 'string1',
48           order   => '15',
49         }
50         concat::fragment { '2':
51           target  => '#{@basedir}/foo',
52           content => 'string2',
53           # default order 10
54         }
55         concat::fragment { '3':
56           target  => '#{@basedir}/foo',
57           content => 'string3',
58           order   => '1',
59         }
60       MANIFEST
61     end
62
63     it 'idempotent, file matches' do
64       idempotent_apply(pp)
65       expect(file("#{@basedir}/foo")).to be_file
66       expect(file("#{@basedir}/foo").content).to match %r{string3string2string1}
67     end
68   end
69
70   describe 'with normal order' do
71     let(:pp) do
72       <<-MANIFEST
73         concat { '#{@basedir}/foo': }
74         concat::fragment { '1':
75           target  => '#{@basedir}/foo',
76           content => 'string1',
77           order   => '01',
78         }
79         concat::fragment { '2':
80           target  => '#{@basedir}/foo',
81           content => 'string2',
82           order   => '02'
83         }
84         concat::fragment { '3':
85           target  => '#{@basedir}/foo',
86           content => 'string3',
87           order   => '03',
88         }
89       MANIFEST
90     end
91
92     it 'idempotent, file matches' do
93       idempotent_apply(pp)
94       expect(file("#{@basedir}/foo")).to be_file
95       expect(file("#{@basedir}/foo").content).to match %r{string1string2string3}
96     end
97   end
98 end