diff --git a/lib/puppet/catalog-diff/comparer.rb b/lib/puppet/catalog-diff/comparer.rb index 23d3994..c5da47b 100644 --- a/lib/puppet/catalog-diff/comparer.rb +++ b/lib/puppet/catalog-diff/comparer.rb @@ -53,7 +53,7 @@ def compare_resources(old, new, options) if options[:show_resource_diff] Puppet.debug("Resource diff: #{resource[:resource_id]}") - puts 'show_resource_diff' + diff_array = str_diff( Puppet::CatalogDiff::Formater.new.resource_to_string(resource), Puppet::CatalogDiff::Formater.new.resource_to_string(new_resource), @@ -138,20 +138,13 @@ def str_diff(cont1, cont2) sum2 = Digest::MD5.hexdigest(str2) end - puts "str_diff: str1: #{str1} str1.encoding: #{str1.encoding}" - puts "str_diff: str2: #{str2} str2.encoding: #{str2.encoding}" unless str1.valid_encoding? Puppet::debug("content parameter in old resource has invalid #{str1.encoding} encoding.") str1.encode!('UTF-8', 'UTF-8', :invalid => :replace) - puts "str_diff: str1 fixed str1: #{str1} str1.encoding: #{str1.encoding}" - unless str1.valid_encoding? - puts "str1 STILL WRONG!" - end end unless str2.valid_encoding? Puppet::debug("content parameter in new resource has invalid #{str2.encoding} encoding.") str2.encode!('UTF-8', 'UTF-8', :invalid => :replace) - puts "str2 fixed str2: #{str2} str2.encoding: #{str2.encoding}" end return nil unless str1 && str2 diff --git a/spec/unit/puppet/catalog_diff/comparer_spec.rb b/spec/unit/puppet/catalog_diff/comparer_spec.rb index 603e9e6..c37f5ba 100644 --- a/spec/unit/puppet/catalog_diff/comparer_spec.rb +++ b/spec/unit/puppet/catalog_diff/comparer_spec.rb @@ -86,18 +86,12 @@ Encoding.default_internal = 'UTF-8' Encoding.default_external = 'UTF-8' # Needed because diff uses tempfile. - puts "Encoding.default_internal: #{Encoding.default_internal}" latin1_string = [246].pack('C*').force_encoding('UTF-8') res1[0][:parameters][:content] = latin1_string - puts "latin1_string.encoding: #{latin1_string.encoding}" - #puts "latin1_string: #{latin1_string}" - #puts "latin1_string.bytes: #{latin1_string.bytes}" expect{compare_resources(res1, res2, show_resource_diff: true)}.not_to raise_error(ArgumentError) diffs = compare_resources(res1, res2, show_resource_diff: true) - #puts "diffs: #{diffs}" - puts "diffs: #{diffs[:string_diffs]['file.foo'][3].bytes}" + ruby_default_replacement_string_for_invalid_characters = '�' - expect(diffs[:string_diffs]['file.foo'][3]).to \ eq("-\t content => \"" + ruby_default_replacement_string_for_invalid_characters + "\"") end