json_api_assert icon indicating copy to clipboard operation
json_api_assert copied to clipboard

Unable to detect if attributes are missing from the actual JSON response

Open brzpegasus opened this issue 8 years ago • 0 comments

Version

Currently using the latest code from master

Issue

I was trying to use assert_data to assert that the server's JSON response included all the required attributes for a given resource.

In a test, I'm updating a resource by sending a PATCH request with some JSON API data. I then assert that the update is successful and that the server responds with data that matches the payload provided.

conn
|> patch(foo_resource_path(conn, :update, payload["id"]), payload)
|> json_response(200)
|> assert_data(payload)

Expected behavior

If the server fails to include certain attributes in the response (because they're not listed in the view), but the payload passed to assert_data does include them, I was expecting the function to detect this.

Actual behavior

The test passes when an attribute that's included in the expected payload does not in fact appear in the response. On the other hand, when the server response includes an attribute that is not in the payload argument, then the test fails as expected.

brzpegasus avatar Oct 06 '17 16:10 brzpegasus