aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-08-14 20:22:11 +0200
committerKasper Timm Hansen <kaspth@gmail.com>2016-08-14 20:22:11 +0200
commitdd344a0eb525e1619f6ae7271ae8343dd71e47d3 (patch)
tree5e151c6d3cd53fd76e8937ccf4aa163f9887a101
parent26ff8dd76bf13edff3977f38e8defbd2a957cd27 (diff)
downloadrails-dd344a0eb525e1619f6ae7271ae8343dd71e47d3.tar.gz
rails-dd344a0eb525e1619f6ae7271ae8343dd71e47d3.tar.bz2
rails-dd344a0eb525e1619f6ae7271ae8343dd71e47d3.zip
[ci skip] Update integration test request encoding documentation.
* Give the section a header to distinguish it from the general doc. * Replace backticks with + signs to fit SDoc. * Use double quoted strings. * Clarify how `parsed_body` works — it doesn't depend on `as` anymore.
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb27
1 files changed, 14 insertions, 13 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index 9be3759556..d213a1c886 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -667,38 +667,39 @@ module ActionDispatch
# end
# end
#
+ # === Changing the request encoding
+ #
# You can also test your JSON API easily by setting what the request should
# be encoded as:
#
- # require 'test_helper'
+ # require "test_helper"
#
# class ApiTest < ActionDispatch::IntegrationTest
- # test 'creates articles' do
+ # test "creates articles" do
# assert_difference -> { Article.count } do
- # post articles_path, params: { article: { title: 'Ahoy!' } }, as: :json
+ # post articles_path, params: { article: { title: "Ahoy!" } }, as: :json
# end
#
# assert_response :success
- # assert_equal({ id: Arcticle.last.id, title: 'Ahoy!' }, response.parsed_body)
+ # assert_equal({ id: Arcticle.last.id, title: "Ahoy!" }, response.parsed_body)
# end
# end
#
- # The `as` option sets the format to JSON, sets the content type to
- # 'application/json' and encodes the parameters as JSON.
+ # The +as+ option sets the format to JSON, sets the content type to
+ # "application/json" and encodes the parameters as JSON.
#
- # Calling `parsed_body` on the response parses the response body as what
- # the last request was encoded as. If the request wasn't encoded `as` something,
- # it's the same as calling `body`.
+ # Calling +parsed_body+ on the response parses the response body based on the
+ # last response MIME type.
#
- # For any custom MIME Types you've registered, you can even add your own encoders with:
+ # For any custom MIME types you've registered, you can even add your own encoders with:
#
# ActionDispatch::IntegrationTest.register_encoder :wibble,
# param_encoder: -> params { params.to_wibble },
# response_parser: -> body { body }
#
- # Where `param_encoder` defines how the params should be encoded and
- # `response_parser` defines how the response body should be parsed through
- # `parsed_body`.
+ # Where +param_encoder+ defines how the params should be encoded and
+ # +response_parser+ defines how the response body should be parsed through
+ # +parsed_body+.
#
# Consult the Rails Testing Guide for more.