From 066b08e68f50ad821fa8e2c2a2e0cda754b9585d Mon Sep 17 00:00:00 2001 From: Dalibor Nasevic Date: Tue, 26 Aug 2025 13:15:58 +0200 Subject: [PATCH] Fix failing tests with rexml 3.4.2 --- lib/simplecov-cobertura.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/simplecov-cobertura.rb b/lib/simplecov-cobertura.rb index f508e30..3371758 100644 --- a/lib/simplecov-cobertura.rb +++ b/lib/simplecov-cobertura.rb @@ -33,8 +33,11 @@ def format(result) private def result_to_xml(result) - doc = REXML::Document.new set_xml_head + doc = REXML::Document.new doc.context[:attribute_quote] = :quote + doc << REXML::XMLDecl.new('1.0') + doc << REXML::DocType.new('coverage', "SYSTEM \"#{DTD_URL}\"") + doc << REXML::Comment.new("Generated by simplecov-cobertura version #{VERSION} (https://github.com/jessebs/simplecov-cobertura)") doc.add_element REXML::Element.new('coverage') coverage = doc.root @@ -140,13 +143,6 @@ def set_branch_attributes(line, file_line, branched_lines, branched_lines_covere end end - def set_xml_head(lines=[]) - lines << "" - lines << "" - lines << "" - lines.join("\n") - end - # Roughly mirrors private method SimpleCov::Formatter::HTMLFormatter#output_coverage def output_message(result, output_path) output = "Coverage report generated for #{result.command_name} to #{output_path}."