diff options
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 |