Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PragTob opened this issue Apr 16, 2024 · 3 comments · May be fixed by #2771
Closed

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

PragTob opened this issue Apr 16, 2024 · 3 comments · May be fixed by #2771

Comments

@PragTob
Copy link

PragTob commented Apr 16, 2024

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

@twalpole
Copy link
Member

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
Copy link
Author

PragTob commented Apr 17, 2024

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

@PragTob
Copy link
Author

PragTob commented Jun 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants