From 059e797a42716ca3bc4d63203dc1f683fd1b9625 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 22 Sep 2014 23:33:39 +0200 Subject: [PATCH] Re-organized some of the CSS lexer tests. --- spec/oga/css/lexer/namespaces_spec.rb | 21 +++++++++++++++++++++ spec/oga/css/lexer/paths_spec.rb | 25 ------------------------- spec/oga/css/lexer/predicates_spec.rb | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 spec/oga/css/lexer/namespaces_spec.rb create mode 100644 spec/oga/css/lexer/predicates_spec.rb diff --git a/spec/oga/css/lexer/namespaces_spec.rb b/spec/oga/css/lexer/namespaces_spec.rb new file mode 100644 index 0000000..b65785e --- /dev/null +++ b/spec/oga/css/lexer/namespaces_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Oga::CSS::Lexer do + context 'namespaces' do + example 'lex a path containing a namespace name' do + lex_css('foo|bar').should == [ + [:T_IDENT, 'foo'], + [:T_PIPE, nil], + [:T_IDENT, 'bar'] + ] + end + + example 'lex a path containing a namespace wildcard' do + lex_css('*|foo').should == [ + [:T_IDENT, '*'], + [:T_PIPE, nil], + [:T_IDENT, 'foo'] + ] + end + end +end diff --git a/spec/oga/css/lexer/paths_spec.rb b/spec/oga/css/lexer/paths_spec.rb index 7d70fa0..cab0636 100644 --- a/spec/oga/css/lexer/paths_spec.rb +++ b/spec/oga/css/lexer/paths_spec.rb @@ -38,30 +38,5 @@ describe Oga::CSS::Lexer do example 'lex a wildcard path' do lex_css('*').should == [[:T_IDENT, '*']] end - - example 'lex a path containing a namespace name' do - lex_css('foo|bar').should == [ - [:T_IDENT, 'foo'], - [:T_PIPE, nil], - [:T_IDENT, 'bar'] - ] - end - - example 'lex a path containing a namespace wildcard' do - lex_css('*|foo').should == [ - [:T_IDENT, '*'], - [:T_PIPE, nil], - [:T_IDENT, 'foo'] - ] - end - - example 'lex a path containing a simple predicate' do - lex_css('foo[bar]').should == [ - [:T_IDENT, 'foo'], - [:T_LBRACK, nil], - [:T_IDENT, 'bar'], - [:T_RBRACK, nil] - ] - end end end diff --git a/spec/oga/css/lexer/predicates_spec.rb b/spec/oga/css/lexer/predicates_spec.rb new file mode 100644 index 0000000..53438a4 --- /dev/null +++ b/spec/oga/css/lexer/predicates_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe Oga::CSS::Lexer do + context 'predicates' do + example 'lex a path containing a simple predicate' do + lex_css('foo[bar]').should == [ + [:T_IDENT, 'foo'], + [:T_LBRACK, nil], + [:T_IDENT, 'bar'], + [:T_RBRACK, nil] + ] + end + end +end