diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2013-03-15 02:16:52 -0700 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2013-03-15 02:16:52 -0700 |
commit | ddb9040b433b00aa0206442aa718eee12bceb517 (patch) | |
tree | c87f2a7a1643772a81161b2d4ea53474df07130d /guides/source | |
parent | c1003d99b00b3afb5417b6853a3e2ba92638cbe8 (diff) | |
parent | e8598a53a17da5fa909e6e5ec1d8284fca6a85f9 (diff) | |
download | rails-ddb9040b433b00aa0206442aa718eee12bceb517.tar.gz rails-ddb9040b433b00aa0206442aa718eee12bceb517.tar.bz2 rails-ddb9040b433b00aa0206442aa718eee12bceb517.zip |
Merge pull request #9716 from senny/rework_headers_functional_tests
Rework headers functional tests
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/testing.md | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/guides/source/testing.md b/guides/source/testing.md index 40bf2603c4..1937cbf17a 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -501,6 +501,21 @@ You also have access to three instance variables in your functional tests: * `@request` - The request * `@response` - The response +### Setting Headers and CGI variables + +Headers and cgi variables can be set directly on the `@request` +instance variable: + +```ruby +# setting a HTTP Header +@request.headers["Accepts"] = "text/plain, text/html" +get :index # simulate the request with custom header + +# setting a CGI variable +@request.headers["HTTP_REFERER"] = "http://example.com/home" +post :create # simulate the request with custom env variable +``` + ### Testing Templates and Layouts If you want to make sure that the response rendered the correct template and layout, you can use the `assert_template` |