From efeb38699a945b3f0432bebd7d4577b873256772 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 18 May 2015 21:44:00 +0200 Subject: [PATCH] HTML closing specs for the "body" element --- .../xml/lexer/html_closing_rules/body_spec.rb | 37 +++++++++++++++++++ .../xml/lexer/html_closing_rules/head_spec.rb | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 spec/oga/xml/lexer/html_closing_rules/body_spec.rb diff --git a/spec/oga/xml/lexer/html_closing_rules/body_spec.rb b/spec/oga/xml/lexer/html_closing_rules/body_spec.rb new file mode 100644 index 0000000..c732205 --- /dev/null +++ b/spec/oga/xml/lexer/html_closing_rules/body_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Oga::XML::Lexer do + describe 'using HTML elements' do + it 'lexes an unclosed followed by a as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'body', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'head', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes an unclosed followed by a as separate elements' do + lex_html('foobar').should == [ + [:T_ELEM_NAME, 'body', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_NAME, 'body', 1], + [:T_TEXT, 'bar', 1], + [:T_ELEM_END, nil, 1] + ] + end + + it 'lexes a

following an unclosed as a child element' do + lex_html('

foo').should == [ + [:T_ELEM_NAME, 'body', 1], + [:T_ELEM_NAME, 'p', 1], + [:T_TEXT, 'foo', 1], + [:T_ELEM_END, nil, 1], + [:T_ELEM_END, nil, 1] + ] + end + end +end diff --git a/spec/oga/xml/lexer/html_closing_rules/head_spec.rb b/spec/oga/xml/lexer/html_closing_rules/head_spec.rb index 583f696..d5248af 100644 --- a/spec/oga/xml/lexer/html_closing_rules/head_spec.rb +++ b/spec/oga/xml/lexer/html_closing_rules/head_spec.rb @@ -24,7 +24,7 @@ describe Oga::XML::Lexer do ] end - it 'lexes a followed an unclosed <head> as a child element' do + it 'lexes a <title> following an unclosed <head> as a child element' do lex_html('<head><title>foo').should == [ [:T_ELEM_NAME, 'head', 1], [:T_ELEM_NAME, 'title', 1],