Call to_s on expression passed to CSS::split - Issue #2093

This commit is contained in:
Thomas Walpole 2018-09-03 20:38:41 -07:00
parent e1161bd4e3
commit edc8a25f0b
2 changed files with 8 additions and 1 deletions

View File

@ -30,7 +30,7 @@ module Capybara
class Splitter
def split(css)
selectors = []
StringIO.open(css) do |str|
StringIO.open(css.to_s) do |str|
selector = ''
while (char = str.getc)
case char

View File

@ -10,6 +10,13 @@ Capybara::SpecHelper.spec '#has_css?' do
expect(@session).to have_css('p a#foo')
end
it 'should take a symbol as the selector' do
# This was never a specifically accepted format but it has worked for a
# lot of versions. Probably should keep it until at least 4.0
# TODO: consider not supporting symbol for the CSS selector.
expect(@session).to have_css(:p)
end
it 'should be false if the given selector is not on the page' do
expect(@session).not_to have_css('abbr')
expect(@session).not_to have_css('p a#doesnotexist')