cucumber-rails icon indicating copy to clipboard operation
cucumber-rails copied to clipboard

Check for RSpec::Matchers rather than requiring it in begin/rescue block

Open jsmestad opened this issue 5 years ago • 4 comments

Summary

I am working on a project where MiniTest and rspec-mocks, rspec-expectations are both available in the Gemfile. However we have RSpec disabled as we do not use RSpec assertions in Cucumber. This is causing an issue with cucumber-rails where it tries to load RSpec expectations and matchers regardless of them being necessary.

Expected Behavior

Tests run fine without RSpec getting loaded when the Gemfile has require: false for those libraries.

Current Behavior

assert_equal with capybara fails due to rspec-expectations changing its behavior from vanilla minitest.

Possible Solution

Changing line the lib/rspec.rb file to check for defined?(RSpec::Mock) would allow for these two libraries to co-exist without causing a conflict.

jsmestad avatar Nov 01 '19 15:11 jsmestad

Sounds good to me @jsmestad - could you send us a PR for this please?

aslakhellesoy avatar Nov 01 '19 16:11 aslakhellesoy

Ah you did already :-) https://github.com/cucumber/cucumber-rails/issues/446

aslakhellesoy avatar Nov 01 '19 16:11 aslakhellesoy

Please ignore my last comment - time to log off for the weekend :-)

aslakhellesoy avatar Nov 01 '19 16:11 aslakhellesoy

As an update to any new contributor / interested party. The main issue with this is that we assume you want to use rspec. As such it isn't required to enable this by the user.

Given the use-case here is to have combinations of gems existing but not functional. One plan of attack (Maybe not the best), is to simply remove all testing requirements. This would require changes of gem packages, require statements - probably meaning a major version bump.

Alternate options are valid, but weren't POC'd.

luke-hill avatar Jun 23 '20 09:06 luke-hill

Closing due to inactivity

luke-hill avatar Sep 10 '24 14:09 luke-hill