teamcapybara / capybara

Acceptance test framework for web applications
http://teamcapybara.github.io/capybara/
MIT License
9.98k stars 1.44k forks source link

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

Closed PragTob closed 1 month ago

PragTob commented 1 month ago

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! :green_heart:

Cross reference aruba issue: https://github.com/cucumber/aruba/issues/927

twalpole commented 1 month ago

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

PragTob commented 1 month ago

@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?