Added basic specs for the CSS parser.
This commit is contained in:
parent
773ff4ce45
commit
665d5fe08c
|
@ -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
|
|
@ -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.
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue