# -*- coding: utf-8 -*-
require "helper"
module Nokogiri
module XML
module SAX
class TestPushParser < Nokogiri::SAX::TestCase
def setup
super
@parser = XML::SAX::PushParser.new(Doc.new)
end
def test_exception
assert_raises(SyntaxError) do
@parser << "
Paragraph 1
eoxml assert ! @parser.document.end_document_called @parser.finish assert @parser.document.end_document_called end def test_start_element @parser.<<(<<-eoxml)eoxml assert_equal [["p", [["id", "asdfasdf"]]]], @parser.document.start_elements @parser.<<(<<-eoxml) Paragraph 1
eoxml assert_equal [' This is a comment '], @parser.document.comments @parser.finish end def test_start_element_with_namespaces @parser.<<(<<-eoxml)eoxml assert_equal [["p", [["xmlns:foo", "http://foo.example.com/"]]]], @parser.document.start_elements @parser.<<(<<-eoxml) Paragraph 1
eoxml assert_equal [' This is a comment '], @parser.document.comments @parser.finish end def test_start_element_ns @parser.<<(<<-eoxml)eoxml @parser.<<(<<-eoxml) Paragraph 1
eoxml assert_equal [' This is a comment '], @parser.document.comments @parser.finish end def test_chevron @parser.<<(<<-eoxml)Paragraph 1
eoxml @parser.finish assert_equal [' This is a comment '], @parser.document.comments end def test_default_options assert_equal 0, @parser.options end def test_recover @parser.options |= XML::ParseOptions::RECOVER @parser.<<(<<-eoxml)
Foo