Sha256: 0b4466008f3a4daeb00f8ec78b3ec257f9d89eb3a40471515e78b1cb7eb69ca7

Contents?: true

Size: 1.66 KB

Versions: 11

Compression:

Stored size: 1.66 KB

Contents

require "helper"

module Nokogiri
  module HTML
    module SAX
      class TestParser < Nokogiri::SAX::TestCase
        def setup
          super
          @parser = HTML::SAX::Parser.new(Doc.new)
        end

        def test_parse_empty_document
          # This caused a segfault in libxml 2.6.x
          assert_nothing_raised { @parser.parse '' }
        end

        def test_parse_empty_file
          # Make sure empty files don't break stuff
          empty_file_name =  File.join(Dir.tmpdir, 'bogus.xml')
          FileUtils.touch empty_file_name
          assert_nothing_raised { @parser.parse_file empty_file_name }
        end

        def test_parse_file
          @parser.parse_file(HTML_FILE)
          assert_equal 1110, @parser.document.end_elements.length
        end

        def test_parse_file_nil_argument
          assert_raises(ArgumentError) {
            @parser.parse_file(nil)
          }
        end

        def test_parse_file_non_existant
          assert_raise Errno::ENOENT do
            @parser.parse_file('foo')
          end
        end

        def test_parse_file_with_dir
          assert_raise Errno::EISDIR do
            @parser.parse_file(File.dirname(__FILE__))
          end
        end

        def test_parse_memory_nil
          assert_raise ArgumentError do
            @parser.parse_memory(nil)
          end
        end

        def test_parse_document
          @parser.parse_memory(<<-eoxml)
            <p>Paragraph 1</p>
            <p>Paragraph 2</p>
          eoxml
          assert_equal([["html", []], ["body", []], ["p", []], ["p", []]],
                       @parser.document.start_elements)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
jwagener-nokogiri-1.4.1 test/html/sax/test_parser.rb
nokogiri-1.4.1-x86-mswin32 test/html/sax/test_parser.rb
nokogiri-1.4.1-x86-mingw32 test/html/sax/test_parser.rb
nokogiri-1.4.1-java test/html/sax/test_parser.rb
nokogiri-1.4.1 test/html/sax/test_parser.rb
superfeedr-nokogiri-1.4.0.20091116183308 test/html/sax/test_parser.rb
caring-nokogiri-1.4.1.pre1 test/html/sax/test_parser.rb
nokogiri-1.4.0-java test/html/sax/test_parser.rb
nokogiri-1.4.0-x86-mswin32 test/html/sax/test_parser.rb
nokogiri-1.4.0-x86-mingw32 test/html/sax/test_parser.rb
nokogiri-1.4.0 test/html/sax/test_parser.rb