From 5324665e9f8a6104c79c7798b3e264db2b42c6d7 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Sat, 2 Jul 2016 21:50:49 -0700 Subject: Expand on Instance variables section with an example and specify when the instance variables are set.[ci skip] --- guides/source/testing.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/guides/source/testing.md b/guides/source/testing.md index d4a826cee5..393f3df6ec 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -789,12 +789,25 @@ cookies["are_good_for_u"] cookies[:are_good_for_u] ### Instance Variables Available -You also have access to three instance variables in your functional tests: +You also have access to three instance variables in your functional tests, after a request is made: * `@controller` - The controller processing the request * `@request` - The request object * `@response` - The response object + +```ruby +class ArticlesControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get articles_url + + assert_equal "index", @controller.action_name + assert_equal "application/x-www-form-urlencoded", @request.media_type + assert_match "Articles", @response.body + end +end +``` + ### Setting Headers and CGI variables [HTTP headers](http://tools.ietf.org/search/rfc2616#section-5.3) -- cgit v1.2.3