Add test for escapes in CSS attribute selectors - Issue #1866
This commit is contained in:
parent
fb356c3f6d
commit
db1bbd2c13
|
@ -112,6 +112,17 @@ Capybara::SpecHelper.spec '#has_css?' do
|
|||
expect(@session).not_to have_css("p a", text: /Red$/)
|
||||
end
|
||||
end
|
||||
|
||||
it "should allow escapes in the CSS selector" do
|
||||
if (defined?(TestClass) && @session.is_a?(TestClass)) || @session.driver.is_a?(Capybara::RackTest::Driver)
|
||||
# Nokogiri doesn't unescape CSS selectors when converting from CSS to XPath
|
||||
# See: https://github.com/teamcapybara/capybara/issues/1866
|
||||
# Also: https://github.com/sparklemotion/nokogiri/pull/1646
|
||||
pending "Current Nokogiri doesn't handle escapes in CSS attribute selectors correctly"
|
||||
end
|
||||
expect(@session).to have_css('p[data-random="abc\\\\def"]')
|
||||
expect(@session).to have_css("p[data-random='#{Capybara::Selector::CSS.escape('abc\def')}']")
|
||||
end
|
||||
end
|
||||
|
||||
Capybara::SpecHelper.spec '#has_no_css?' do
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<span class="number">42</span>
|
||||
<span>Other span</span>
|
||||
|
||||
<p class="para" id="first">
|
||||
<p class="para" id="first" data-random="abc\def">
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
||||
tempor incididunt ut <a href="/with_simple_html" title="awesome title" class="simple">labore</a>
|
||||
et dolore magna aliqua. Ut enim ad minim veniam,
|
||||
|
|
Loading…
Reference in New Issue