Passing the Request Test
Explore how to pass request tests by debugging the registrations controller in Rails. Understand parameter permissions, strong parameters, and status code handling to ensure your tests accurately reflect application behavior. This lesson guides you through solving common request test failures and adjusting expectations for realistic outcomes.
We'll cover the following...
Why did the test fail?
Now, we need to find out why the test is failing.
We could look at the test.log file, but it’s of no help in this case. So, we’ll have to check out the registrations controller. To do that, we’’ll use the generator that Devise provides.
$ rails g devise:controllers users -c=registrations
create app/controllers/users/registrations_controller.rb
The generator also gives us some code to add into our config/routes.rb file.
It’s now a lot easier to see what happens with the request.
Let’s uncomment the create action in the registrations controller and add a breakpoint (with pry).
The test should now ...