Track document types when parsing.

When parsing XML/HTML documents the corresponding document type (:html or :xml)
is stored in Document#type.
This commit is contained in:
Yorick Peterse committed 2014-09-16 00:25:51 +02:00
1 parent bd322e8716
commit 6fc7e2e254
4 files changed
+32 -2

No files matched your search

+4
View File
@@ -8,6 +8,10 @@ describe Oga::XML::Document do
document.children[0].should == child
end
example 'set the document type' do
described_class.new(:type => :html).type.should == :html
end
end
context '#children=' do
+18
View File
@@ -11,6 +11,20 @@ describe Oga::XML::Parser do
end
end
context 'XML documents' do
before :all do
@document = parse('<foo></foo>')
end
example 'return a Document instance' do
@document.is_a?(Oga::XML::Document).should == true
end
example 'set the document type' do
@document.type.should == :xml
end
end
context 'HTML documents' do
before :all do
html = <<-EOF.strip
@@ -31,6 +45,10 @@ describe Oga::XML::Parser do
@document.is_a?(Oga::XML::Document).should == true
end
example 'set the document type' do
@document.type.should == :html
end
example 'set the doctype of the document' do
@document.doctype.is_a?(Oga::XML::Doctype).should == true
end