Sha256: d8d843d474b4dcf1b32514efd5a474cc2c6ab64c1ca3003c3418638830266775

Contents?: true

Size: 1.69 KB

Versions: 36

Compression:

Stored size: 1.69 KB

Contents

module DocumentXMLHelper
  def text(xml)
    Nokogiri::XML(xml).text.gsub(/\s+/, " ").strip
  end

  def assert_xml_equal(expected, actual)
    doc1 = XmlSimple.xml_in(document_xml(expected))
    doc2 = XmlSimple.xml_in(actual)
    assert_equal JSON.pretty_generate(doc1), JSON.pretty_generate(doc2)
  end

  def document_xml(content)
    <<-documentxml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14">
  <w:body>
    #{content}
  </w:body>
</w:document>
    documentxml
  end

  def wrap(xml)
    Nokogiri::XML(document_xml(xml))
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
sablon-0.4.1 test/support/document_xml_helper.rb
sablon-0.4.0 test/support/document_xml_helper.rb
sablon-0.3.2 test/support/document_xml_helper.rb
sablon-0.3.1 test/support/document_xml_helper.rb
sablon-0.3.0 test/support/document_xml_helper.rb
sablon-0.2.1 test/support/document_xml_helper.rb
sablon-0.2.0 test/support/document_xml_helper.rb
sablon-0.1.1 test/support/document_xml_helper.rb
sablon-0.1.0 test/support/document_xml_helper.rb
sablon-0.0.22 test/support/document_xml_helper.rb
sablon-0.0.21 test/support/document_xml_helper.rb
sablon-0.0.20 test/support/document_xml_helper.rb
sablon-0.0.19 test/support/document_xml_helper.rb
sablon-0.0.19.beta5 test/support/document_xml_helper.rb
sablon-0.0.19.beta4 test/support/document_xml_helper.rb
sablon-0.0.19.beta3 test/support/document_xml_helper.rb
sablon-0.0.19.beta2 test/support/document_xml_helper.rb
sablon-0.0.19.beta1 test/support/document_xml_helper.rb
sablon-0.0.18 test/support/document_xml_helper.rb
sablon-0.0.17 test/support/document_xml_helper.rb