1 require 'spec_helper_acceptance'
7 scriptname = 'concatfragments.rb'
8 vardir = default['puppetvardir']
12 scriptname = 'concatfragments.rb'
13 vardir = default['puppetvardir']
15 username = 'Administrator'
16 groupname = 'Administrators'
17 scriptname = 'concatfragments.rb'
18 result = on default, "echo #{default['puppetvardir']}"
19 vardir = result.raw_output.chomp
23 scriptname = 'concatfragments.rb'
24 vardir = default['puppetvardir']
28 scriptname = 'concatfragments.rb'
29 vardir = default['puppetvardir']
32 describe 'basic concat test' do
33 basedir = default.tmpdir('concat')
34 safe_basedir = basedir.gsub(/[\/:]/, '_')
36 shared_examples 'successfully_applied' do |pp|
37 it 'applies the manifest twice with no stderr' do
38 apply_manifest(pp, :catch_failures => true)
39 apply_manifest(pp, :catch_changes => true)
42 describe file("#{vardir}/concat") do
43 it { should be_directory }
44 it { should be_owned_by username }
45 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
49 describe file("#{vardir}/concat/bin") do
50 it { should be_directory }
51 it { should be_owned_by username }
52 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
56 describe file("#{vardir}/concat/bin/#{scriptname}") do
58 it { should be_owned_by username }
59 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
63 describe file("#{vardir}/concat/#{safe_basedir}_file") do
64 it { should be_directory }
65 it { should be_owned_by username }
66 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
70 describe file("#{vardir}/concat/#{safe_basedir}_file/fragments") do
71 it { should be_directory }
72 it { should be_owned_by username }
73 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
77 describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat") do
79 it { should be_owned_by username }
80 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
84 describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat.out") do
86 it { should be_owned_by username }
87 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
93 context 'owner/group root' do
103 concat { '#{basedir}/file':
104 owner => '#{username}',
105 group => '#{groupname}',
109 concat::fragment { '1':
110 target => '#{basedir}/file',
115 concat::fragment { '2':
116 target => '#{basedir}/file',
122 it_behaves_like 'successfully_applied', pp
124 describe file("#{basedir}/file") do
125 it { should be_file }
126 it { should be_owned_by username }
127 it("should be group", :unless => (fact('osfamily') == 'windows')) { should be_grouped_into groupname }
128 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
136 describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do
137 it { should be_file }
138 it { should be_owned_by username }
139 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
143 describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/02_2") do
144 it { should be_file }
145 it { should be_owned_by username }
146 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
153 context 'works when set to present with path set' do
165 path => '#{basedir}/file',
168 concat::fragment { '1':
175 it_behaves_like 'successfully_applied', pp
177 describe file("#{basedir}/file") do
178 it { should be_file }
179 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
182 its(:content) { should match '1' }
185 context 'works when set to absent with path set' do
197 path => '#{basedir}/file',
200 concat::fragment { '1':
207 it 'applies the manifest twice with no stderr' do
208 apply_manifest(pp, :catch_failures => true)
209 apply_manifest(pp, :catch_changes => true)
212 describe file("#{basedir}/file") do
213 it { should_not be_file }