spec/spec_helper.rb in asciimath2unitsml-0.4.3 vs spec/spec_helper.rb in asciimath2unitsml-0.4.4

- old
+ new

@@ -8,11 +8,10 @@ SimpleCov.start "gem" require "asciimath2unitsml" require "rspec/matchers" require "equivalent-xml/rspec_matchers" -require "rexml/document" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = ".rspec_status" @@ -23,11 +22,17 @@ c.syntax = :expect end end def xmlpp(xml) - s = "" - f = REXML::Formatters::Pretty.new(2) - f.compact = true - f.write(REXML::Document.new(xml), s) - s + xsl = <<~XSL + <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:output method="xml" encoding="UTF-8" indent="yes"/> + <xsl:strip-space elements="*"/> + <xsl:template match="/"> + <xsl:copy-of select="."/> + </xsl:template> + </xsl:stylesheet> + XSL + Nokogiri::XSLT(xsl).transform(Nokogiri::XML(xml, &:noblanks)) + .to_xml(indent: 2, encoding: "UTF-8") end