summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorEric Putnam <putnam.eric@gmail.com>2017-07-26 11:51:10 -0700
committerGitHub <noreply@github.com>2017-07-26 11:51:10 -0700
commitd65a144aea0cd73f4aaa0cef15c74414baba5c8d (patch)
tree24e6a37d40538ad62db736c227f4f7438495d042 /spec
parent4a658957db669efef666feb61b5d5c1406d105e9 (diff)
parent703fa777e1daee97e2aea529064d773662ef1fe0 (diff)
Merge pull request #717 from ripclawffb/filelineoption
Add new file_line option append_on_no_match
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/puppet/provider/file_line/ruby_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb
index ab6edf9..dcca4a4 100755
--- a/spec/unit/puppet/provider/file_line/ruby_spec.rb
+++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb
@@ -194,6 +194,24 @@ describe provider_class, :unless => Puppet::Util::Platform.windows? do
@provider.create
expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2")
end
+
+ it 'should not add line after no matches found' do
+ @resource = Puppet::Type::File_line.new(
+ {
+ :name => 'foo',
+ :path => @tmpfile,
+ :line => 'inserted = line',
+ :match => '^foo3$',
+ :append_on_no_match => false,
+ }
+ )
+ @provider = provider_class.new(@resource)
+ File.open(@tmpfile, 'w') do |fh|
+ fh.write("foo1\nfoo = blah\nfoo2\nfoo = baz")
+ end
+ expect(@provider.exists?).to be true
+ expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = blah\nfoo2\nfoo = baz")
+ end
end
describe 'using after' do