diff options
author | David Schmitt <david.schmitt@puppetlabs.com> | 2015-05-29 10:21:41 +0100 |
---|---|---|
committer | David Schmitt <david.schmitt@puppetlabs.com> | 2015-05-29 10:21:41 +0100 |
commit | 4a8c0a57f2c4df4e2e3fa37466f02a7f6fccd517 (patch) | |
tree | ee3a9e21d41ee70b94e8d8eb2dcd7a94e2bdeb82 /spec | |
parent | c9b810cf365cbc4f87dfcee8b4eedf0b055e3569 (diff) | |
parent | 72089f3d134a00e64f0b3d81237a266131d40412 (diff) |
Merge pull request #463 from CENGN/fix/master/file_line_multiple_after
(MODULES-2071) Patch file_line provider to use multiple with after
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/unit/puppet/provider/file_line/ruby_spec.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb index a84fc78..8fe3932 100755 --- a/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb @@ -201,7 +201,7 @@ describe provider_class do end end - context 'with two lines matching the after expression' do + context 'with multiple lines matching the after expression' do before :each do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo = blah\nfoo2\nfoo1\nfoo = baz") @@ -211,6 +211,22 @@ describe provider_class do it 'errors out stating "One or no line must match the pattern"' do expect { provider.create }.to raise_error(Puppet::Error, /One or no line must match the pattern/) end + + it 'adds the line after all lines matching the after expression' do + @resource = Puppet::Type::File_line.new( + { + :name => 'foo', + :path => @tmpfile, + :line => 'inserted = line', + :after => '^foo1$', + :multiple => true, + } + ) + @provider = provider_class.new(@resource) + expect(@provider.exists?).to be_nil + @provider.create + expect(File.read(@tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo1\ninserted = line\nfoo = baz") + end end context 'with no lines matching the after expression' do |