{"action":"created","issue":{"url":"https://api.github.com/repos/DockYard/json_api_assert/issues/21","repository_url":"https://api.github.com/repos/DockYard/json_api_assert","labels_url":"https://api.github.com/repos/DockYard/json_api_assert/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/DockYard/json_api_assert/issues/21/comments","events_url":"https://api.github.com/repos/DockYard/json_api_assert/issues/21/events","html_url":"https://github.com/DockYard/json_api_assert/issues/21","id":172338084,"number":21,"title":"New API and library rename","user":{"login":"bcardarella","id":18524,"avatar_url":"https://avatars.githubusercontent.com/u/18524?v=3","gravatar_id":"","url":"https://api.github.com/users/bcardarella","html_url":"https://github.com/bcardarella","followers_url":"https://api.github.com/users/bcardarella/followers","following_url":"https://api.github.com/users/bcardarella/following{/other_user}","gists_url":"https://api.github.com/users/bcardarella/gists{/gist_id}","starred_url":"https://api.github.com/users/bcardarella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcardarella/subscriptions","organizations_url":"https://api.github.com/users/bcardarella/orgs","repos_url":"https://api.github.com/users/bcardarella/repos","events_url":"https://api.github.com/users/bcardarella/events{/privacy}","received_events_url":"https://api.github.com/users/bcardarella/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-21T20:00:01Z","updated_at":"2016-08-22T06:48:47Z","closed_at":null,"body":"New name: `jassert` or `jassert`\r\n\r\nOne function that `conn` can be pipped through. The following API:\r\n\r\n* `jassert(conn)` - creates a new map `%{payload: JSON.parse(conn.body), status: conn.status}`\r\n\r\nThis function should be the first connection used. It will parse the `conn`s `body` into a payload object.\r\n*Will* assert that the payload is a properly formed `json-api` payload.\r\n*Will* assert that the proper response headers are included.\r\n*Will* assert that `jsonapi` object exists with correct meta data in the root of the document.\r\nThe `payload` and the response `status` are then stored in a new map object that can be consumed by corresponding `jassert` functions.\r\n\r\n* `jassert(payload, :data, data)`\r\n\r\nThis function will assert that `data` is contained in the `data` object of the payload.\r\nIf `data` is a list it will iterate over each member of the list and assert each individually.\r\nIf `payload.status == 201` the `id` of `data` *WON'T* be expected. The `data` object on the `payload` *MUST* return a *single* resource object otherwise assertion fails.\r\n\r\n* `jassert(payload, :included, included_data)`\r\n\r\nThis function will assert that `included_data` is contained in the `included` object of the payload. If `included_data` is a list it will iterate over each member of the list and assert each individually.\r\n\r\n* `jassert(payload, {:data, :included}, data, :relationship, type, relationship_data)`\r\n\r\nThis function will assert that `relationship_data` is setup as a relationship for the given data. The path is followed either down `data` or `included`. The `type` can be singular or plural.\r\nIf `relationship_data` is a list each member of the list is asserted.\r\n\r\n* `jassert(payload, :links, link_data)`\r\n\r\nThis function will assert that `link_data` exists in the root of the document.\r\n\r\n* `jassert(payload, {:data, :included}, data, :links, link_data)`\r\n\r\nThis function will assert that `link_data` exists in the `data` resource object on the proper path.\r\n\r\n* `jassert(payload, {:data, :included}, data, :relationship, type, relationship_data, :links, link_data)`\r\n\r\nThis function will assert that `link_data` exists on the given relationship for the given resource object.\r\n\r\n* `jassert(payload, :meta, meta_data)`\r\n\r\nThis function will assert that `meta_data` exists in the root of the document\r\n\r\n* `jassert(payload, {:data, :included}, data, :meta, meta_data)`\r\n\r\nThis function will assert that `meta_data` exists in the given resource object\r\n\r\n* `jassert(payload, {:data, :included}, data, :relationship, type, relationship_data, :meta, meta_data)`\r\n\r\nThis function will assert that `meta_data` exists on the given relationship for the given resource object"},"comment":{"url":"https://api.github.com/repos/DockYard/json_api_assert/issues/comments/241327576","html_url":"https://github.com/DockYard/json_api_assert/issues/21#issuecomment-241327576","issue_url":"https://api.github.com/repos/DockYard/json_api_assert/issues/21","id":241327576,"user":{"login":"codyjroberts","id":6867961,"avatar_url":"https://avatars.githubusercontent.com/u/6867961?v=3","gravatar_id":"","url":"https://api.github.com/users/codyjroberts","html_url":"https://github.com/codyjroberts","followers_url":"https://api.github.com/users/codyjroberts/followers","following_url":"https://api.github.com/users/codyjroberts/following{/other_user}","gists_url":"https://api.github.com/users/codyjroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/codyjroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codyjroberts/subscriptions","organizations_url":"https://api.github.com/users/codyjroberts/orgs","repos_url":"https://api.github.com/users/codyjroberts/repos","events_url":"https://api.github.com/users/codyjroberts/events{/privacy}","received_events_url":"https://api.github.com/users/codyjroberts/received_events","type":"User","site_admin":false},"created_at":"2016-08-22T06:48:47Z","updated_at":"2016-08-22T06:48:47Z","body":"> New name: `jassert` or `jassert`\r\n\r\n😆 \r\n\r\nThis looks great.  I really like the idea of `jassert(conn)`.  I was wondering how we would go about testing the status codes, and of course `conn` makes this so easy. \r\n\r\n>  Will assert that jsonapi object exists with correct meta data in the root of the document.\r\n\r\nThis is currently optional according to spec.  If we require it, I think we should also require the version to be included in the meta data.\r\n\r\nPlease let me know if I can help in any way.\r\n"}}
{"actor":{"display_login":"codyjroberts"}}