Initial specs for parsing CSS IDs/classes.

This commit is contained in:
Yorick Peterse 2014-10-07 19:01:04 +02:00
parent 09315ea478
commit 6e18287a1d
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,21 @@
require 'spec_helper'
describe Oga::CSS::Parser do
context 'classes' do
example 'parse a class selector' do
parse_css('.foo').should == s(:class, 'foo')
end
example 'parse a selector for an element with a class' do
parse_css('foo.bar').should == s(:class, 'bar', s(:test, nil, 'foo'))
end
example 'parse a selector using multiple classes' do
parse_css('.foo.bar').should == s(:class, 'bar', s(:class, 'foo'))
end
example 'parse a selector using a class and an ID' do
parse_css('#foo.bar').should == s(:class, 'bar', s(:id, 'foo'))
end
end
end

View File

@ -0,0 +1,17 @@
require 'spec_helper'
describe Oga::CSS::Parser do
context 'IDs' do
example 'parse an ID selector' do
parse_css('#foo').should == s(:id, 'foo')
end
example 'parse a selector for an element with an ID' do
parse_css('foo#bar').should == s(:id, 'bar', s(:test, nil, 'foo'))
end
example 'parse a selector using an ID and a class' do
parse_css('.foo#bar').should == s(:id, 'bar', s(:class, 'foo'))
end
end
end