CheeseFry
CheeseFry

Reputation: 1319

How to make Minitest error codes return error message too?

Getting the following error message.
Expected response to be a <success>, but was <422>

I've got a number of 422 responses each with error messages to help the consumer of my api know what is wrong.
But the 422 I'm getting in Minitest doesn't provide the error message as well.
How can that be included in the error message?

Upvotes: 2

Views: 609

Answers (1)

CheeseFry
CheeseFry

Reputation: 1319

Adding the following code to the assert_response now produces the error message back.

assert_response :success, @response.body.to_s

Or if you need a specific error code.

assert_response 402, @response.body.to_s

Upvotes: 3

Related Questions