diff options
author | Marcel Molina <marcel@vernix.org> | 2007-12-05 14:40:42 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2007-12-05 14:40:42 +0000 |
commit | 096f3f64680c9f19c78999a6b2ffdaca9606403c (patch) | |
tree | a39ab496a03de12da15d0cc8c24c314b2bf694b3 /actionpack/lib/action_controller/assertions/response_assertions.rb | |
parent | da5fef45fe259dc47d00c3c52cfa336ade412645 (diff) | |
download | rails-096f3f64680c9f19c78999a6b2ffdaca9606403c.tar.gz rails-096f3f64680c9f19c78999a6b2ffdaca9606403c.tar.bz2 rails-096f3f64680c9f19c78999a6b2ffdaca9606403c.zip |
Add examples in the documentation for various assertions. Closes #9938 [zapnap]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8284 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/assertions/response_assertions.rb')
-rw-r--r-- | actionpack/lib/action_controller/assertions/response_assertions.rb | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/assertions/response_assertions.rb b/actionpack/lib/action_controller/assertions/response_assertions.rb index 29eb2b033a..1ac0f234d4 100644 --- a/actionpack/lib/action_controller/assertions/response_assertions.rb +++ b/actionpack/lib/action_controller/assertions/response_assertions.rb @@ -14,6 +14,15 @@ module ActionController # You can also pass an explicit status number like assert_response(501) # or its symbolic equivalent assert_response(:not_implemented). # See ActionController::StatusCodes for a full list. + # + # ==== Examples + # + # # assert that the response was a redirection + # assert_response :redirect + # + # # assert that the response code was status code 401 (unauthorized) + # assert_response 401 + # def assert_response(type, message = nil) clean_backtrace do if [ :success, :missing, :redirect, :error ].include?(type) && @response.send("#{type}?") @@ -28,9 +37,18 @@ module ActionController end end - # Assert that the redirection options passed in match those of the redirect called in the latest action. This match can be partial, - # such that assert_redirected_to(:controller => "weblog") will also match the redirection of - # redirect_to(:controller => "weblog", :action => "show") and so on. + # Assert that the redirection options passed in match those of the redirect called in the latest action. + # This match can be partial, such that assert_redirected_to(:controller => "weblog") will also + # match the redirection of redirect_to(:controller => "weblog", :action => "show") and so on. + # + # ==== Examples + # + # # assert that the redirection was to the "index" action on the WeblogController + # assert_redirected_to :controller => "weblog", :action => "index" + # + # # assert that the redirection was to the named route login_url + # assert_redirected_to login_url + # def assert_redirected_to(options = {}, message=nil) clean_backtrace do assert_response(:redirect, message) @@ -104,6 +122,12 @@ module ActionController end # Asserts that the request was rendered with the appropriate template file. + # + # ==== Examples + # + # # assert that the "new" view template was rendered + # assert_template "new" + # def assert_template(expected = nil, message=nil) clean_backtrace do rendered = expected ? @response.rendered_file(!expected.include?('/')) : @response.rendered_file |