diff --git a/spec/oga/parser/cdata_spec.rb b/spec/oga/parser/cdata_spec.rb index d7aecce..896d462 100644 --- a/spec/oga/parser/cdata_spec.rb +++ b/spec/oga/parser/cdata_spec.rb @@ -3,18 +3,18 @@ require 'spec_helper' describe Oga::Parser do context 'cdata tags' do example 'parse a cdata tag' do - parse_html('').should == s(:document, s(:cdata, 'foo')) + parse('').should == s(:document, s(:cdata, 'foo')) end example 'parse an element inside a cdata tag' do - parse_html('foo

]]>').should == s( + parse('foo

]]>').should == s( :document, s(:cdata, '

foo

') ) end example 'parse double brackets inside a cdata tag' do - parse_html('').should == s(:document, s(:cdata, ']]')) + parse('').should == s(:document, s(:cdata, ']]')) end end end diff --git a/spec/oga/parser/comments_spec.rb b/spec/oga/parser/comments_spec.rb index 034da7f..1c87c6d 100644 --- a/spec/oga/parser/comments_spec.rb +++ b/spec/oga/parser/comments_spec.rb @@ -3,11 +3,11 @@ require 'spec_helper' describe Oga::Parser do context 'comments' do example 'parse an empty comment' do - parse_html('').should == s(:document, s(:comment)) + parse('').should == s(:document, s(:comment)) end example 'parse a comment' do - parse_html('').should == s(:document, s(:comment, 'foo')) + parse('').should == s(:document, s(:comment, 'foo')) end end end diff --git a/spec/oga/parser/doctype_spec.rb b/spec/oga/parser/doctype_spec.rb index 5457220..301b7e2 100644 --- a/spec/oga/parser/doctype_spec.rb +++ b/spec/oga/parser/doctype_spec.rb @@ -3,25 +3,25 @@ require 'spec_helper' describe Oga::Parser do context 'doctypes' do example 'parse a doctype' do - parse_html('').should == s(:document, s(:doctype)) + parse('').should == s(:document, s(:doctype)) end example 'parse a doctype with the doctype type' do - parse_html('').should == s( + parse('').should == s( :document, s(:doctype, 'PUBLIC') ) end example 'parse a doctype with a public ID' do - parse_html('').should == s( + parse('').should == s( :document, s(:doctype, 'PUBLIC', 'foo') ) end example 'parse a doctype with a public and private ID' do - parse_html('').should == s( + parse('').should == s( :document, s(:doctype, 'PUBLIC', 'foo', 'bar') ) @@ -31,7 +31,7 @@ describe Oga::Parser do doctype = '' - parse_html(doctype).should == s( + parse(doctype).should == s( :document, s( :doctype, diff --git a/spec/oga/parser/documents_spec.rb b/spec/oga/parser/documents_spec.rb index 90e0c3c..204f8d7 100644 --- a/spec/oga/parser/documents_spec.rb +++ b/spec/oga/parser/documents_spec.rb @@ -13,7 +13,7 @@ describe Oga::Parser do EOF - parse_html(html).should == s( + parse(html).should == s( :document, s(:doctype), s(:text, "\n"), diff --git a/spec/oga/parser/elements_spec.rb b/spec/oga/parser/elements_spec.rb index e366850..9b71b5d 100644 --- a/spec/oga/parser/elements_spec.rb +++ b/spec/oga/parser/elements_spec.rb @@ -3,35 +3,35 @@ require 'spec_helper' describe Oga::Parser do context 'elements' do example 'parse an empty element' do - parse_html('

').should == s( + parse('

').should == s( :document, s(:element, nil, 'p', nil, nil) ) end example 'parse an element with text' do - parse_html('

foo

').should == s( + parse('

foo

').should == s( :document, s(:element, nil, 'p', nil, s(:text, 'foo')) ) end example 'parse an element with a single attribute' do - parse_html('

').should == s( + parse('

').should == s( :document, s(:element, nil, 'p', s(:attributes, s(:attribute, 'foo')), nil) ) end example 'parse an element with a single attribute with a value' do - parse_html('

').should == s( + parse('

').should == s( :document, s(:element, nil, 'p', s(:attributes, s(:attribute, 'foo', 'bar')), nil) ) end example 'parse an element with multiple attributes' do - parse_html('

').should == s( + parse('

').should == s( :document, s( :element, @@ -48,7 +48,7 @@ describe Oga::Parser do end example 'parse an element with text and attributes' do - parse_html('

Bar

').should == s( + parse('

Bar

').should == s( :document, s( :element, @@ -61,14 +61,14 @@ describe Oga::Parser do end example 'parse an element with a namespace' do - parse_html('

').should == s( + parse('

').should == s( :document, s(:element, 'foo', 'p', nil, nil) ) end example 'parse an element with a namespace and an attribute' do - parse_html('

').should == s( + parse('

').should == s( :document, s( :element, @@ -81,14 +81,14 @@ describe Oga::Parser do end example 'parse an element nested inside another element' do - parse_html('

').should == s( + parse('

').should == s( :document, s(:element, nil, 'p', nil, s(:element, nil, 'a', nil, nil)) ) end example 'parse an element with children text, element' do - parse_html('

FooBar

').should == s( + parse('

FooBar

').should == s( :document, s( :element, @@ -102,7 +102,7 @@ describe Oga::Parser do end example 'parse an element with children text, element, text' do - parse_html('

FooBarBaz

').should == s( + parse('

FooBarBaz

').should == s( :document, s( :element, @@ -117,7 +117,7 @@ describe Oga::Parser do end example 'parse an element with children element, text' do - parse_html('

BarBaz

').should == s( + parse('

BarBaz

').should == s( :document, s( :element, @@ -131,7 +131,7 @@ describe Oga::Parser do end example 'parse an element with children element, text, element' do - parse_html('

BarBazDa

').should == s( + parse('

BarBazDa

').should == s( :document, s( :element, diff --git a/spec/oga/parser/general_spec.rb b/spec/oga/parser/general_spec.rb index 9dd2fef..94bd0d1 100644 --- a/spec/oga/parser/general_spec.rb +++ b/spec/oga/parser/general_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' describe Oga::Parser do example 'parse regular text' do - parse_html('foo').should == s(:document, s(:text, 'foo')) + parse('foo').should == s(:document, s(:text, 'foo')) end example 'parse a newline' do - parse_html("\n").should == s(:document, s(:text, "\n")) + parse("\n").should == s(:document, s(:text, "\n")) end end diff --git a/spec/oga/parser/html_void_elements_spec.rb b/spec/oga/parser/html_void_elements_spec.rb index 666007c..74d135e 100644 --- a/spec/oga/parser/html_void_elements_spec.rb +++ b/spec/oga/parser/html_void_elements_spec.rb @@ -3,21 +3,21 @@ require 'spec_helper' describe Oga::Parser do context 'HTML void elements' do example 'parse a void element that omits the closing /' do - parse_html('').should == s( + parse('', :html => true).should == s( :document, s(:element, nil, 'link', nil, nil) ) end example 'parse a void element inside another element' do - parse_html('').should == s( + parse('', :html => true).should == s( :document, s(:element, nil, 'head', nil, s(:element, nil, 'link', nil, nil)) ) end example 'parse a void element with attributes inside another element' do - parse_html('').should == s( + parse('', :html => true).should == s( :document, s( :element, @@ -36,7 +36,7 @@ describe Oga::Parser do end example 'parse a void element and a non void element in the same parent' do - parse_html('Foo').should == s( + parse('Foo', :html => true).should == s( :document, s( :element, diff --git a/spec/support/parsing.rb b/spec/support/parsing.rb index 6a0fa5a..8bb26c9 100644 --- a/spec/support/parsing.rb +++ b/spec/support/parsing.rb @@ -26,10 +26,11 @@ module Oga # Parses the given HTML and returns an AST. # # @param [String] input + # @param [Hash] options # @return [Oga::AST::Node] # - def parse_html(input) - return Oga::Parser.new(:html => true).parse(input) + def parse(input, options = {}) + return Oga::Parser.new(options).parse(input) end end # ParsingHelpers end # Oga