From 354fb73ff26452be52656c793502431f03a05563 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Fri, 12 Feb 2016 20:04:29 +0100 Subject: 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. --- actionpack/CHANGELOG.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'actionpack/CHANGELOG.md') 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* -- cgit v1.2.3