What to Expect in a Request Spec
Learn about requests and behavior testing in requests spec, hash variables, HTTP response codes verification, and controller redirection.
Behavior testing
Our main goal in a request spec is to test behavior. We find that test-double validations work well here. If we’re interested in testing the final state after the request, in addition to testing the changes to the database, there are a few other substantive things we can test.
response
variable access
After the request has been made, we have access to a response
variable. Since request specs wrap Rails integration tests, RSpec does render the view, though if we are testing view behavior, we recommend using system specs, where we have access to the Capybara matchers and not just the Rails integration spec matchers as described in Minitest.
Hash variables
After the request has been made, we ...