From 6eaa592cd8d5af097a4624b3d1cead74408aabf2 Mon Sep 17 00:00:00 2001 From: Stephen Benjamin Date: Wed, 14 May 2014 20:33:57 +0200 Subject: (PUP-2571) add 'before' functionality to file_line file_line supports adding lines after a match, but there are use cases when having "before" would be useful. For example, in Debian-based OS's, the last line of /etc/rc.local is "exit 0" it's an incredible pain to deal with that scenario today. This commit adds a 'before' parameter to the file_line type, and implements it for the ruby provider. --- spec/unit/puppet/type/file_line_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'spec/unit/puppet/type/file_line_spec.rb') diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index ab5b81b..b85b9f4 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -15,6 +15,14 @@ describe Puppet::Type.type(:file_line) do file_line[:match] = '^foo.*$' file_line[:match].should == '^foo.*$' end + it 'should accept an after regex' do + file_line[:after] = '^foo.*$' + file_line[:after].should == '^foo.*$' + end + it 'should accept a before regex' do + file_line[:before] = '^foo.*$' + file_line[:before].should == '^foo.*$' + end it 'should not accept a match regex that does not match the specified line' do expect { Puppet::Type.type(:file_line).new( -- cgit v1.2.3