Added basic specs for the CSS parser.

This commit is contained in:
Yorick Peterse 2014-10-05 01:28:31 +02:00
parent 773ff4ce45
commit 665d5fe08c
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,17 @@
require 'spec_helper'
describe Oga::CSS::Parser do
context 'paths' do
example 'parse a single path' do
parse_css('foo').should == s(:test, nil, 'foo')
end
example 'parse a path using two selectors' do
parse_css('foo bar').should == s(
:path,
s(:test, nil, 'foo'),
s(:test, nil, 'bar')
)
end
end
end

View File

@ -42,6 +42,14 @@ module Oga
return Oga::CSS::Lexer.new(input).lex
end
##
# @param [String] input
# @return [AST::Node]
#
def parse_css(input)
return Oga::CSS::Parser.new(input).parse
end
##
# Parses an XPath expression.
#