From 46e3a2349e9eef4001db8be9581fae9dfbccaf14 Mon Sep 17 00:00:00 2001 From: Geoff Williams Date: Tue, 14 Mar 2017 01:24:36 +1100 Subject: (#FM-6068) allow file encoding to be specified (#726) * (#FM-6068) allow file encoding to be specified Add a new parameter `encoding` to allow non UTF-8 files to specify a file encoding. This prevents receiving the error message "invalid byte sequence in UTF-8" when special characters that are not UTF-8 encoded appear in the input stream, such as the copyright symbol. * (#FM-6068) allow file encoding to be specified Added docs and tests as requested --- spec/unit/puppet/type/file_line_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'spec/unit') diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index 7da8a7d..150149b 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -87,7 +87,12 @@ describe Puppet::Type.type(:file_line) do it 'should default to replace => true' do expect(file_line[:replace]).to eq :true end - + it 'should default to encoding => UTF-8' do + expect(file_line[:encoding]).to eq 'UTF-8' + end + it 'should accept encoding => iso-8859-1' do + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :present, :encoding => 'iso-8859-1', :line => 'bar') }.not_to raise_error + end it "should autorequire the file it manages" do catalog = Puppet::Resource::Catalog.new file = Puppet::Type.type(:file).new(:name => tmp_path) -- cgit v1.2.3