diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-02-12 20:04:29 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2016-02-12 20:13:48 +0100 |
commit | 354fb73ff26452be52656c793502431f03a05563 (patch) | |
tree | d9f1b737d58618cddfe301c6d4e65d438498c584 /actionpack | |
parent | d50d7094247aad5005cd1b47258ddf338b0dddd7 (diff) | |
download | rails-354fb73ff26452be52656c793502431f03a05563.tar.gz rails-354fb73ff26452be52656c793502431f03a05563.tar.bz2 rails-354fb73ff26452be52656c793502431f03a05563.zip |
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.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG.md | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 77aa4c01ba..b3283c1974 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -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,10 +29,19 @@ 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* |