From 35e92645f727f02ef9ace8948154079bc0fff05a Mon Sep 17 00:00:00 2001 From: Raymond Maika Date: Thu, 30 Jul 2015 14:05:39 -0400 Subject: (MODULES-2024) Adding replace attribute to file_line --- spec/unit/puppet/type/file_line_spec.rb | 3 +++ 1 file changed, 3 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 410d0bf..58c88e3 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -49,6 +49,9 @@ describe Puppet::Type.type(:file_line) do it 'should default to ensure => present' do expect(file_line[:ensure]).to eq :present end + it 'should default to replace => true' do + expect(file_line[:replace]).to eq true + end it "should autorequire the file it manages" do catalog = Puppet::Resource::Catalog.new -- cgit v1.2.3 From a7adcda803abe82e6a16e2410c10d58abedbd82d Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Tue, 4 Aug 2015 09:59:53 +0100 Subject: (MODULES-2316) Change file_type boolean parameter to symbols Puppet's boolean parameter type is only available in Puppet 3.3 and higher, so change file_type's new "replace" parameter to a regular parameter with true and false as possible values. This matches the existing "multiple" parameter. --- spec/unit/puppet/type/file_line_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 58c88e3..f1430f2 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -50,7 +50,7 @@ describe Puppet::Type.type(:file_line) do expect(file_line[:ensure]).to eq :present end it 'should default to replace => true' do - expect(file_line[:replace]).to eq true + expect(file_line[:replace]).to eq :true end it "should autorequire the file it manages" do -- cgit v1.2.3 From 7e408ca7970fd172822db02227935798f9ff282f Mon Sep 17 00:00:00 2001 From: Johnson Earls Date: Mon, 28 Mar 2016 20:59:27 +0000 Subject: [MODULES-2370] file_line.rb: Fix `line` attribute validation `file_line` type: During validation, do not require `line` attribute if: * `ensure` is `absent`, * `match` is not empty, * and `match_for_absence` is `true`. Also update `spec` tests to reflect this. --- spec/unit/puppet/type/file_line_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (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 f1430f2..48e2670 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -41,10 +41,13 @@ describe Puppet::Type.type(:file_line) do expect { file_line[:path] = 'file' }.to raise_error(Puppet::Error, /File paths must be fully qualified/) end it 'should require that a line is specified' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file') }.to raise_error(Puppet::Error, /Both line and path are required attributes/) + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file') }.to raise_error(Puppet::Error, /line is a required attribute/) + end + 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/file', :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, /Both line and path are required attributes/) + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, /path is a required attribute/) end it 'should default to ensure => present' do expect(file_line[:ensure]).to eq :present -- cgit v1.2.3