nil response object in Rails 5.2, RSpec-Rails 3.7 spec for GET request
I'm sure you've probably already solved this, but for anyone else who might stumble upon this, we ran into the same thing (response
not being assigned after a request way made - either get
or post
, didn't try other methods, but assume they would all be the same). Existing request specs that had been working all started failing.
The culprit in our case was tracked down to a module that was required in rails_helper.rb
, and added to rspec's config.include
list:
config.include ApiHelper, type: request
Inside AppHelper
was the root cause:
include Rack::Test::Methods
Commenting that line out (and ultimately for us, removing the entire helper as it wasn't really needed) restored the request specs to their previous, and working, state.
tl;dr:
Make sure you're not including Rack::Test::Methods
in config.include
for your rspec config inadvertently.