Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / concat / spec / acceptance / newline_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'concat ensure_newline parameter' do
4   before(:all) do
5     @basedir = setup_test_directory
6   end
7   describe 'when false' do
8     let(:pp) do
9       <<-MANIFEST
10       concat { '#{@basedir}/file':
11         ensure_newline => false,
12       }
13       concat::fragment { '1':
14         target  => '#{@basedir}/file',
15         content => '1',
16       }
17       concat::fragment { '2':
18         target  => '#{@basedir}/file',
19         content => '2',
20       }
21     MANIFEST
22     end
23
24     it 'applies the manifest twice with no stderr' do
25       idempotent_apply(pp)
26       expect(file("#{@basedir}/file")).to be_file
27       expect(file("#{@basedir}/file").content).to match '12'
28     end
29   end
30
31   describe 'when true' do
32     let(:pp) do
33       <<-MANIFEST
34       concat { '#{@basedir}/file':
35         ensure_newline => true,
36       }
37       concat::fragment { '1':
38         target  => '#{@basedir}/file',
39         content => '1',
40       }
41       concat::fragment { '2':
42         target  => '#{@basedir}/file',
43         content => '2',
44       }
45     MANIFEST
46     end
47
48     it 'applies the manifest twice with no stderr' do
49       idempotent_apply(pp)
50       expect(file("#{@basedir}/file")).to be_file
51       expect(file("#{@basedir}/file").content).to match %r{1\r?\n2\r?\n}
52     end
53   end
54 end