From 10d0ec1573d30166d45cff01d66d0a90759a61ee Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 7 Apr 2014 21:33:23 +0200 Subject: [PATCH] Specs for parsing various empty nodes. --- spec/oga/xml/parser/cdata_spec.rb | 4 ++++ spec/oga/xml/parser/documents_spec.rb | 4 ++++ spec/oga/xml/parser/xml_declaration_spec.rb | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/oga/xml/parser/cdata_spec.rb b/spec/oga/xml/parser/cdata_spec.rb index cc60a26..269681d 100644 --- a/spec/oga/xml/parser/cdata_spec.rb +++ b/spec/oga/xml/parser/cdata_spec.rb @@ -2,6 +2,10 @@ require 'spec_helper' describe Oga::XML::Parser do context 'cdata tags' do + example 'parse an empty cdata tag' do + parse('').should == s(:document, s(:cdata)) + end + example 'parse a cdata tag' do parse('').should == s(:document, s(:cdata, 'foo')) end diff --git a/spec/oga/xml/parser/documents_spec.rb b/spec/oga/xml/parser/documents_spec.rb index 40fa432..3eef8d0 100644 --- a/spec/oga/xml/parser/documents_spec.rb +++ b/spec/oga/xml/parser/documents_spec.rb @@ -2,6 +2,10 @@ require 'spec_helper' describe Oga::XML::Parser do context 'HTML documents' do + example 'parse an empty document' do + parse('').should == s(:document) + end + example 'parse a basic HTML document' do html = <<-EOF diff --git a/spec/oga/xml/parser/xml_declaration_spec.rb b/spec/oga/xml/parser/xml_declaration_spec.rb index ba6a17b..60778ab 100644 --- a/spec/oga/xml/parser/xml_declaration_spec.rb +++ b/spec/oga/xml/parser/xml_declaration_spec.rb @@ -2,7 +2,11 @@ require 'spec_helper' describe Oga::XML::Parser do context 'XML declaration tags' do - example 'lex an XML declaration tag' do + example 'parse an empty XML declaration tag' do + parse('').should == s(:document, s(:xml_decl)) + end + + example 'parse an XML declaration tag' do parse('').should == s( :document, s(:xml_decl, s(:attributes, s(:attribute, 'version', '1.0')))