Sha256: 8db930146ac20519f0cc0f47d996c89e673f6ad752c115e6ac391ab985dc207e

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

require "helper"

module Nokogiri
  module XML
    class TestText < Nokogiri::TestCase
      def test_inspect
        node = Text.new('hello world', Document.new)
        assert_equal "#<#{node.class.name}:#{sprintf("0x%x",node.object_id)} #{node.text.inspect}>", node.inspect
      end

      def test_new
        node = Text.new('hello world', Document.new)
        assert node
        assert_equal('hello world', node.content)
        assert_instance_of Nokogiri::XML::Text, node
      end

      def test_lots_of_text
        100.times { Text.new('hello world', Document.new) }
      end

      # No assertion because this was a segv
      def test_new_without_document
        doc = Document.new
        node = Nokogiri::XML::Element.new('foo', doc)
        text = Text.new('hello world', node)
      end

      def test_content=
        node = Text.new('foo', Document.new)
        assert_equal('foo', node.content)
        node.content = '& <foo> &amp;'
        assert_equal('& <foo> &amp;', node.content)
        assert_equal('&amp; &lt;foo&gt; &amp;amp;', node.to_xml)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
glebm-nokogiri-1.4.2.1 test/xml/test_text.rb
nokogiri-1.5.0.beta.1 test/xml/test_text.rb
nokogiri-1.4.2.1-x86-mswin32 test/xml/test_text.rb
nokogiri-1.4.2.1-x86-mingw32 test/xml/test_text.rb
nokogiri-1.5.0.beta.1-java test/xml/test_text.rb
nokogiri-1.4.2-java test/xml/test_text.rb
nokogiri-1.4.2 test/xml/test_text.rb