teamcapybara / capybara

Acceptance test framework for web applications

Home Page:http://teamcapybara.github.io/capybara/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clash on `all` method with aruba/rspec-expectations in cucumber

PragTob opened this issue · comments

Heyo, thanks for all your work on capybara!

Meta

capybara (3.40.0)
Ruby 3.3

Issue & reproduction

I have documented and reproduced the issue in this repo: https://github.com/PragTob/all_conflict

Most basically the capybara DSL method all clashes with all of rspec-expectations which aruba uses. This conflict must have come in some version update and so I'm unable to upgrade gem versions in simplecov.

I'm not sure about the best solution. I couldn't find it in the docs, but if one could use capybara with the DSL not being global but bound to a page as it is in some setups (but seemingly not with cucumber) that should solve the issue.


Thanks a lot for all your work! 💚

Cross reference aruba issue: cucumber/aruba#927

This happened years ago when especially added their ‘all’ method and were unwilling to work on a solution. If RSpec is shadowing Capybara you can use the ‘find_all’ alias in Capybara. Otherwise Capybara,, iassuming its included correctly, installs proxies which should be calling the correct version of ‘all’ based on passed parameter types - https://github.com/teamcapybara/capybara/blob/master/lib/capybara/rspec/matcher_proxies.rb

@twalpole hey, thank you but have you seen the reproduction repo - it's a minimized example of just a few lines and it's definitely happening. It shows how the source of the method changes and the test starts failing once capybara is required along with a warning that it will also raise in future versions of capybara.

I'm not sure why the matcher_proxies aren't there - it might be because the tests I'm running are in cucumber and I'm requiring 'capybara/cucumber' - maybe the proxy isn't installed then even if rspec is present?

Hey @twalpole / whoever,

as outlined above I continue to believe this is an actual problem as shown in the minimized example. I've found a workaround via some debugging: PragTob/all_conflict#1

-require 'aruba/cucumber'
 require 'capybara/cucumber'
+require 'aruba/cucumber'
 
+Aruba::Api::Core.include(::Capybara::RSpecMatcherProxies)

I'm also reasonably sure capybara is included correctly there (as you can see in the diff above). It just seems that the work around for install the proxy is too specific and doesn't cover the use case that comes up with aruba - hence including it manually in the relevant module fixes it.

I'm not too familiar with the code there and hence couldn't come out with a good fix (as I also don't know why some of the protections are in place).

I seem to have half-way successfully included this workaround in simplecov, but would really appreciate a more general solution. simplecov-ruby/simplecov#1088