Rack::Test provides the last_response method for checking HTTP responses. Add the following line inside your spec, right after the post request:
You’ve encountered code like this before, in Your First Spec. It’s an expectation fulfilling the role an assertion method would play in other test frameworks.
Together, expect() and to() check a result in order to signal success or failure. They compare a value—in this case, the HTTP status code returned by last_response.status—using a matcher. Here, we create a matcher using the eq method, which indicates whether or not the value wrapped by expect equals ...