Sha256: d907bf2a2374d90b50ccfcf3f57a451bfa165a18bb2a34d66c22fea06ad07ba5

Contents?: true

Size: 1.32 KB

Versions: 78

Compression:

Stored size: 1.32 KB

Contents

require "helper"

module Nokogiri
  module XML
    class TestText < Nokogiri::TestCase
      def test_css_path
        doc  = Nokogiri.XML "<root> foo <a>something</a> bar bazz </root>"
        node = doc.root.children[2]
        assert_instance_of Nokogiri::XML::Text, node
        assert_equal node, doc.at_css(node.css_path)
      end

      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

      def test_new_without_document
        doc = Document.new
        node = Nokogiri::XML::Element.new('foo', doc)

        assert_nothing_raised do
          Text.new('hello world', node)
        end
      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

78 entries across 78 versions & 12 rubygems

Version Path
nokogiri-maglev--1.5.2 test/xml/test_text.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/test/xml/test_text.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/test/xml/test_text.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/test/xml/test_text.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/test/xml/test_text.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/test/xml/test_text.rb
ftl-0.2.0 vendor/bundle/gems/nokogiri-1.5.2/test/xml/test_text.rb
horseman-0.0.5 vendor/ruby/1.9.1/gems/nokogiri-1.5.2/test/xml/test_text.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/nokogiri-1.5.2/test/xml/test_text.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/nokogiri-1.5.2/test/xml/test_text.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/nokogiri-1.5.2/test/xml/test_text.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/nokogiri-1.5.2/test/xml/test_text.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/nokogiri-1.5.2/test/xml/test_text.rb
nokogiri-1.5.3.rc2-java test/xml/test_text.rb
nokogiri-1.5.3.rc2-x86-mingw32 test/xml/test_text.rb
nokogiri-1.5.3.rc2-x86-mswin32-60 test/xml/test_text.rb
nokogiri-1.5.3.rc2 test/xml/test_text.rb
nokogiri-1.5.2 test/xml/test_text.rb
nokogiri-1.5.2-x86-mswin32-60 test/xml/test_text.rb
nokogiri-1.5.2-x86-mingw32 test/xml/test_text.rb