1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Flesh out request encoding + response parsing changelog entry.

Add more info about the APIs added and how they work.

Use string keys when comparing the parsed response, like how JSON would
be parsed.
This commit is contained in:
Kasper Timm Hansen 2016-02-12 20:04:29 +01:00
parent d50d709424
commit 354fb73ff2

View file

@ -13,7 +13,7 @@
headers: { 'Content-Type' => 'application/json' }
end
assert_equal({ id: Article.last.id, title: 'Ahoy!' }, JSON.parse(response.body))
assert_equal({ 'id' => Article.last.id, 'title' => 'Ahoy!' }, JSON.parse(response.body))
end
end
```
@ -29,11 +29,20 @@
post articles_path, { article: { title: 'Ahoy!' } }, as: :json
end
assert_equal({ id: Article.last.id, title: 'Ahoy!' }, response.parsed_body)
assert_equal({ 'id' => Article.last.id, 'title' => 'Ahoy!' }, response.parsed_body)
end
end
```
Passing `as: :json` to integration test request helpers will set the format,
content type and encode the parameters as JSON.
Then on the response side, `parsed_body` will parse the body according to the
content type the response has.
Currently JSON is the only supported MIME type. Add your own with
`ActionDispatch::IntegrationTest.register_encoder`.
*Kasper Timm Hansen*
* Add image/svg+xml as a default mime type.