diff options
author | Alex Harvey <Alex_Harvey@amp.com.au> | 2017-09-29 16:14:37 +1000 |
---|---|---|
committer | Alex Harvey <Alex_Harvey@amp.com.au> | 2017-09-29 16:25:47 +1000 |
commit | ad5d92461596d8d0b1c001d49061d70b36761d59 (patch) | |
tree | 4b601143c1d4e665e8a715596bfb5fbd87f17801 /spec/unit/puppet/type/file_line_spec.rb | |
parent | 2b2b3870ec1737dc78ec402c2dccbb7b65a2ef8f (diff) |
(maint) Clarify docs and add new tests
Based on a Stack Overflow question, it was noted that the documentation
for `file_line` isn't complete and the underlying behaviour somewhat
confusing.
https://stackoverflow.com/questions/46468922/how-to-change-the-contents-of-a-file-by-using-puppet/46473458
In this patch I add additional unit tests and better examples and
complete documentation.
Diffstat (limited to 'spec/unit/puppet/type/file_line_spec.rb')
-rwxr-xr-x | spec/unit/puppet/type/file_line_spec.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index 150149b..db07352 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -78,6 +78,9 @@ describe Puppet::Type.type(:file_line) do it 'should not require that a line is specified when matching for absence' do expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error end + it 'although if a line is specified anyway when matching for absence it still works and the line is silently ignored' do + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :line => 'i_am_irrelevant', :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error + end it 'should require that a file is specified' do expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, /path is a required attribute/) end |