1 require 'spec_helper_acceptance'
3 test_file = (os[:family] == 'windows') ? 'C:\Users\Administrator\file_line_test.txt' : '/tmp/file_line_test.txt'
5 describe 'file_line type' do
7 pp_test_file = <<-MANIFEST
10 content => 'a wild test file has appeared!',
13 apply_manifest(pp_test_file)
16 context 'ensure line' do
19 file_line { 'test_ensure':
20 path => '#{test_file}',
21 line => 'test file uses attack!',
26 it 'applies manifest, adds line' do
28 expect(file(test_file)).to be_file
29 expect(file(test_file).content).to match(%r{test file uses attack!})
33 context 'matches and replaces line' do
36 file_line { 'test_match':
37 path => '#{test_file}',
38 line => 'a tame test file has appeared!',
44 it 'applies manifest, replaces line' do
46 expect(file(test_file)).to be_file
47 expect(file(test_file).content).to match(%r{a tame test file has appeared!})
51 context 'remove line' do
52 context 'using match' do
55 file_line { 'test_absent_match':
57 path => '#{test_file}',
59 match_for_absence => true,
64 it 'applies manifest, removes line' do
66 expect(file(test_file)).to be_file
67 expect(file(test_file).content).to be_empty
71 context 'using line' do
74 file_line { 'test_absent_line':
76 path => '#{test_file}',
77 line => 'a wild test file has appeared!',
82 it 'applies manifest, removes line' do
84 expect(file(test_file)).to be_file
85 expect(file(test_file).content).to be_empty