From 665d5fe08c0d5e0af32c82e0a9ac8734e0cb74ef Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Sun, 5 Oct 2014 01:28:31 +0200 Subject: [PATCH] Added basic specs for the CSS parser. --- spec/oga/css/parser/paths_spec.rb | 17 +++++++++++++++++ spec/support/parsing.rb | 8 ++++++++ 2 files changed, 25 insertions(+) create mode 100644 spec/oga/css/parser/paths_spec.rb diff --git a/spec/oga/css/parser/paths_spec.rb b/spec/oga/css/parser/paths_spec.rb new file mode 100644 index 0000000..39af30e --- /dev/null +++ b/spec/oga/css/parser/paths_spec.rb @@ -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 diff --git a/spec/support/parsing.rb b/spec/support/parsing.rb index 122cb63..dfc9b3d 100644 --- a/spec/support/parsing.rb +++ b/spec/support/parsing.rb @@ -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. #