Specs for parsing various empty nodes.

This commit is contained in:
Yorick Peterse 2014-04-07 21:33:23 +02:00
parent cb74c7edf9
commit 10d0ec1573
3 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,10 @@ require 'spec_helper'
describe Oga::XML::Parser do describe Oga::XML::Parser do
context 'cdata tags' do context 'cdata tags' do
example 'parse an empty cdata tag' do
parse('<![CDATA[]]>').should == s(:document, s(:cdata))
end
example 'parse a cdata tag' do example 'parse a cdata tag' do
parse('<![CDATA[foo]]>').should == s(:document, s(:cdata, 'foo')) parse('<![CDATA[foo]]>').should == s(:document, s(:cdata, 'foo'))
end end

View File

@ -2,6 +2,10 @@ require 'spec_helper'
describe Oga::XML::Parser do describe Oga::XML::Parser do
context 'HTML documents' do context 'HTML documents' do
example 'parse an empty document' do
parse('').should == s(:document)
end
example 'parse a basic HTML document' do example 'parse a basic HTML document' do
html = <<-EOF html = <<-EOF
<!DOCTYPE html> <!DOCTYPE html>

View File

@ -2,7 +2,11 @@ require 'spec_helper'
describe Oga::XML::Parser do describe Oga::XML::Parser do
context 'XML declaration tags' do context 'XML declaration tags' do
example 'lex an XML declaration tag' do example 'parse an empty XML declaration tag' do
parse('<?xml?>').should == s(:document, s(:xml_decl))
end
example 'parse an XML declaration tag' do
parse('<?xml version="1.0" ?>').should == s( parse('<?xml version="1.0" ?>').should == s(
:document, :document,
s(:xml_decl, s(:attributes, s(:attribute, 'version', '1.0'))) s(:xml_decl, s(:attributes, s(:attribute, 'version', '1.0')))