Sha256: eb1f9b01efa1608c1e23a1fbfa79e106ce28f0a981e005c3b5433a11422ca984

Contents?: true

Size: 1.51 KB

Versions: 18

Compression:

Stored size: 1.51 KB

Contents

# Copyright (C) 2013  Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

class TestDecomposersXML < Test::Unit::TestCase
  include Helper

  def setup
    @decomposer = ChupaText::Decomposers::XML.new({})
  end

  sub_test_case("decompose") do
    def test_body
      xml = <<-XML
<root>
  Hello
  <sub-element attribute="value">&amp;</sub-element>
  World
</root>
      XML
      text = <<-TEXT

  Hello
  &
  World

      TEXT
      assert_equal([text],
                   decompose(xml).collect(&:body))
    end

    private
    def decompose(xml)
      data = ChupaText::Data.new
      data.path = "hello.xml"
      data.mime_type = "text/xml"
      data.body = xml

      decomposed = []
      @decomposer.decompose(data) do |decomposed_data|
        decomposed << decomposed_data
      end
      decomposed
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
chupa-text-1.1.7 test/decomposers/test-xml.rb
chupa-text-1.1.6 test/decomposers/test-xml.rb
chupa-text-1.1.5 test/decomposers/test-xml.rb
chupa-text-1.1.4 test/decomposers/test-xml.rb
chupa-text-1.1.3 test/decomposers/test-xml.rb
chupa-text-1.1.2 test/decomposers/test-xml.rb
chupa-text-1.1.1 test/decomposers/test-xml.rb
chupa-text-1.1.0 test/decomposers/test-xml.rb
chupa-text-1.0.9 test/decomposers/test-xml.rb
chupa-text-1.0.8 test/decomposers/test-xml.rb
chupa-text-1.0.7 test/decomposers/test-xml.rb
chupa-text-1.0.6 test/decomposers/test-xml.rb
chupa-text-1.0.5 test/decomposers/test-xml.rb
chupa-text-1.0.4 test/decomposers/test-xml.rb
chupa-text-1.0.3 test/decomposers/test-xml.rb
chupa-text-1.0.2 test/decomposers/test-xml.rb
chupa-text-1.0.1 test/decomposers/test-xml.rb
chupa-text-1.0.0 test/decomposers/test-xml.rb