diff --git a/spec/oga/lexer/comments_spec.rb b/spec/oga/lexer/comments_spec.rb index cd2b2bf..254bb22 100644 --- a/spec/oga/lexer/comments_spec.rb +++ b/spec/oga/lexer/comments_spec.rb @@ -25,5 +25,31 @@ describe Oga::Lexer do [:T_COMMENT_END, '-->', 1, 9] ] end + + example 'lex a comment followed by text' do + lex('foo').should == [ + [:T_COMMENT_START, '', 1, 5], + [:T_TEXT, 'foo', 1, 8] + ] + end + + example 'lex text followed by a comment' do + lex('foo').should == [ + [:T_TEXT, 'foo', 1, 1], + [:T_COMMENT_START, '', 1, 8] + ] + end + + example 'lex an element followed by a comment' do + lex('

').should == [ + [:T_ELEM_OPEN, nil, 1, 1], + [:T_ELEM_NAME, 'p', 1, 2], + [:T_ELEM_CLOSE, nil, 1, 4], + [:T_COMMENT_START, '', 1, 12] + ] + end end end