Fix Spinach and Capybara dependencies
This fixes a problem where all Spinach tests were failing due to the error, "ArgumentError: rack-test requires a rack application, but none was given".
Trying to use the Rack::Test driver in Spinach.hooks.before_run
is a bit tricky. It looks like this driver is registered when capybara/rails
is loaded. However, the Spinach runner does the following things:
- Loads the env.rb and other files in features/support
- Loads the Rails framework
- Runs the
before_run
hook
Attempt to load the capybara/rails
gem before initializing of the framework yields exceptions due to undefined methods and constants.
This MR fixes this by loading the required definitions in the before_run
hook, just as the spinach-rails gem does, which we do not appear to be actually using. Adding require 'spinach-rails'
does not help because registering multiple hooks does not guarantee that the right dependencies will be loaded in time. We can probably remove this gem since we do not appear to be using it.
Closes #30347 (closed)