Testing JSON response in request RSpec tests #5
23nith
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This will come in handy for those who are currently building RSpec tests for their HTTP requests and are expecting a response in JSON format.
At any point within the body of the test code block after the request line, you can outright refer to the response object by its name then simply access its body property via dot-notation, parse it to convert it to JSON. After which you can now access its key value contents (as seen on the above screenshot, the count is being accessed via bracket notation) .
Beta Was this translation helpful? Give feedback.
All reactions