Sha256: 5c1f502cdd2af9073cc0adebc910a2ce6d0ae9e22ab916284847c55c2d77093f

Contents?: true

Size: 1.01 KB

Versions: 165

Compression:

Stored size: 1.01 KB

Contents

require "helper"

module Nokogiri
  module XML
    class TestComment < Nokogiri::TestCase
      def setup
        super
        @xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
      end

      def test_new
        comment = Nokogiri::XML::Comment.new(@xml, 'hello world')
        assert_equal('<!--hello world-->', comment.to_s)
      end

      def test_comment?
        comment = Nokogiri::XML::Comment.new(@xml, 'hello world')
        assert(comment.comment?)
        assert(!@xml.root.comment?)
      end

      def test_passing_a_node_uses_the_node_document
        comment = Nokogiri::XML::Comment.new(@xml.at_css("employee"), 'hello world')
        assert_equal @xml, comment.document
      end

      def test_passing_anything_else
        assert_raises ArgumentError do
          Nokogiri::XML::Comment.new("NOT A NOKOGIRI CLASS", 'hello world')
        end
      end

      def test_many_comments
        100.times {
          Nokogiri::XML::Comment.new(@xml, 'hello world')
        }
      end
    end
  end
end

Version data entries

165 entries across 155 versions & 16 rubygems

Version Path
tdiary-5.0.11 vendor/bundle/gems/nokogiri-1.8.4/test/xml/test_comment.rb
tdiary-5.0.11 vendor/bundle/gems/nokogiri-1.8.5/test/xml/test_comment.rb
nokogiri-1.9.0.rc1 test/xml/test_comment.rb
nokogiri-1.9.0.rc1-x86-mingw32 test/xml/test_comment.rb
nokogiri-1.9.0.rc1-x64-mingw32 test/xml/test_comment.rb
nokogiri-1.9.0.rc1-java test/xml/test_comment.rb
nokogiri-1.8.5 test/xml/test_comment.rb
nokogiri-1.8.5-x86-mingw32 test/xml/test_comment.rb
nokogiri-1.8.5-x64-mingw32 test/xml/test_comment.rb
nokogiri-1.8.5-java test/xml/test_comment.rb
daslabs-0.12.0 vendor/cache/ruby/2.5.0/gems/nokogiri-1.8.2/test/xml/test_comment.rb
daslabs-0.11.0 vendor/cache/ruby/2.5.0/gems/nokogiri-1.8.2/test/xml/test_comment.rb
nokogiri-1.8.4 test/xml/test_comment.rb
nokogiri-1.8.4-x86-mingw32 test/xml/test_comment.rb
nokogiri-1.8.4-x64-mingw32 test/xml/test_comment.rb
nokogiri-1.8.4-java test/xml/test_comment.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/nokogiri-1.8.3/test/xml/test_comment.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.3/test/xml/test_comment.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/nokogiri-1.8.3/test/xml/test_comment.rb
tdiary-5.0.9 vendor/bundle/gems/nokogiri-1.8.2/test/xml/test_comment.rb