I think you have updated not only capybara-webkit, but also capybara.
Capybara 2.1 now uses the CSS selector driver implementation.
It used to work because Capybara converted the CSS selector to XPath using Nokogiri. Nokogiri seems to support the pseudo-selector :contains (since this code worked previously).
You can rewrite it with XPath, for example:
within(:xpath, "//dl[preceding-sibling::h3[contains(text(),'FooBar text')]]") do page.should have_content 'FizzBuzz' end
However, I believe that it is not too readable, so it is better to choose the best selector, which will be shorter and more readable.
source share