summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/provider/file_line/ruby_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/puppet/provider/file_line/ruby_spec.rb')
-rwxr-xr-xspec/unit/puppet/provider/file_line/ruby_spec.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb
index dcf8509..dcca4a4 100755
--- a/spec/unit/puppet/provider/file_line/ruby_spec.rb
+++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb
@@ -190,10 +190,28 @@ describe provider_class, :unless => Puppet::Util::Platform.windows? do
File.open(@tmpfile, 'w') do |fh|
fh.write("foo1\nfoo = bar\nfoo2")
end
- expect(@provider.exists?).to eql(false)
+ expect(@provider.exists?).to eql(true)
@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
@@ -387,7 +405,7 @@ describe provider_class, :unless => Puppet::Util::Platform.windows? do
File.open(@tmpfile, 'w') do |fh|
fh.write("foo1\nfoo\nfoo2")
end
- expect(@provider.exists?).to be_nil
+ expect(@provider.exists?).to eql (true)
end
it 'should remove one line if it matches' do