1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/spec/css_splitter_spec.rb

39 lines
1.1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Capybara::Selector::CSS::Splitter do
let :splitter do
::Capybara::Selector::CSS::Splitter.new
end
2018-07-10 17:18:39 -04:00
context 'split not needed' do
it 'normal CSS selector' do
css = 'div[id="abc"]'
expect(splitter.split(css)).to eq [css]
end
2018-07-10 17:18:39 -04:00
it 'comma in strings' do
css = 'div[id="a,bc"]'
expect(splitter.split(css)).to eq [css]
end
2018-07-10 17:18:39 -04:00
it 'comma in pseudo-selector' do
css = 'div.class1:not(.class1, .class2)'
expect(splitter.split(css)).to eq [css]
end
end
2018-07-10 17:18:39 -04:00
context 'split needed' do
it 'root level comma' do
css = 'div.class1, span, p.class2'
expect(splitter.split(css)).to eq ['div.class1', 'span', 'p.class2']
end
2018-07-10 17:18:39 -04:00
it 'root level comma when quotes and pseudo selectors' do
css = 'div.class1[id="abc\\"def,ghi"]:not(.class3, .class4), span[id=\'a"c\\\'de\'], section, #abc\\,def'
expect(splitter.split(css)).to eq ['div.class1[id="abc\\"def,ghi"]:not(.class3, .class4)', 'span[id=\'a"c\\\'de\']', 'section', '#abc\\,def']
end
end
end