Open trusche opened 6 years ago
Had the same issue during a Rails 5.2 upgrade, tracking master removed the warnings.
These warnings come in hundreds which is quite annoying. What's wrong with a patch release?
Any news on this?
Switching to the branch master
should fix the issue until the next version of capybara-webkit
will be released
# Gemfile
group :test do
gem 'capybara-webkit', github: 'thoughtbot/capybara-webkit', branch: 'master'
end
Any time frame on the next release? Much appreciated, thanks!
After switching to the master branch of capybara-webkit
my features started to fail with
expected to find text "4 Total Users" in "4\nTotal\nUsers\n" (RSpec::Expectations::ExpectationNotMetError)
I decided to switch back to capybara-webkit 1.15.0
and added the following monkey-patch code to the support files to suppress the warning:
# features/support/capybara/helpers.rb
# or
# spec/support/capybara/helpers.rb
module Capybara
module Helpers
class << self
alias_method :normalize_whitespace_with_warning, :normalize_whitespace
def normalize_whitespace(*args)
silence_warnings do
normalize_whitespace_with_warning(*args)
end
end
end
end
end
@Hirurg103 Those errors are because you've updated to Capybara 3 and the master branch of capybara-webkit properly supports Capybara 3 (whereas 1.15.0 does not). The details are in Capybaras upgrade guide - https://github.com/teamcapybara/capybara/blob/master/UPGRADING.md#node. Capybara 3.5.0 also adds a normalize_ws
option to the text matchers -https://github.com/teamcapybara/capybara/blob/3.5_stable/History.md#added - to mimic Capybara 2 behavior if you dont want/need to actually verify the text as displayed
@twalpole with capybara 3.5.0 and capybara-webkit 1.15.0 I had the build green. But after switching to capybara-webkit master branch and leaving capybara version the same it started to fail with the spacing error above
@Hirurg103 Yes. As I stated in my comment capybara-webkit 1.5.0 does not properly support Capybara 3. It doesn't meet the Capybara 3 requirements for returning the text of an element, whereas the master branch does. The errors you get about text matching when using the master branch are correct for Capybara 3 and would be returned if you use any of the other drivers which have released Capybara 3 compliant versions.
@twalpole Before the upgrade I used capybara 2.13.0
and capybara-webkit 1.14.0
and the build was green. After the upgrade to capybara 3.5.0
and capybara-webkit 1.15.0
the build was still green. But after switching to the master branch of capybara-webkit it started to fail. Seems like that there are breaking changes in the master branch of capybara-webkit
@Hirurg103 The breaking changes are from Capybara 2.x to Capybara 3.x as mentioned in the upgrade.md I linked previously - you just didn’t see them until using capybara-webkit’ master branch because
capybara-webkit` 1.15 doesn’t fully support Capybara 3. I don’t know how else to explain it to you. With Capybara 3 your tests SHOULD be failing.
@twalpole thank you for the explanation! Now I see why my build still passing after upgrade to capybara 3 and capybara webkit 1.15.
Here's the fix that worked for me (which @twalpole already mentioned above):
Before
expect(page).to have_content(message)
After
expect(page).to have_content(message, normalize_ws: true)
From my understanding, the normalize_ws
flag just forces Capybara to fallback to the old way of comparing a string. Documentation
@twalpole thanks a lot for the patience 😅 , I haven't read the Capybara upgrade guide for the first time properly
For now, either:
gem "capybara"
gem 'capybara-webkit', git: 'https://github.com/thoughtbot/capybara-webkit.git'
or
gem "capybara", '~>2.0'
gem 'capybara-webkit'
Hi!
Since this commit on Capybara, first released with capybara 3.0.0.rc2, this deprecation warning is thrown:
This seems to be fixed on master in this commit. Any chance of a new release?
Thank you!