diff --git a/lib/capybara/selector/css.rb b/lib/capybara/selector/css.rb index c90cdce6..4cead1bf 100644 --- a/lib/capybara/selector/css.rb +++ b/lib/capybara/selector/css.rb @@ -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 diff --git a/lib/capybara/spec/session/has_css_spec.rb b/lib/capybara/spec/session/has_css_spec.rb index c1989319..40730841 100644 --- a/lib/capybara/spec/session/has_css_spec.rb +++ b/lib/capybara/spec/session/has_css_spec.rb @@ -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')