Created
February 15, 2009 19:21
-
-
Save dchelimsky/64820 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ThingsController < ApplicationController | |
class UnRescuedError < StandardError; end | |
class RescuedError < StandardError; end | |
rescue_from RescuedError do |exception| | |
#no-op | |
end | |
def action_that_raises_rescued_error | |
raise RescuedError | |
end | |
def action_that_raises_un_rescued_error | |
raise UnRescuedError | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby test/functional/things_controller_test.rb | |
Loaded suite test/functional/things_controller_test | |
Started | |
.... | |
Finished in 0.198612 seconds. | |
4 tests, 5 assertions, 0 failures, 0 errors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.join(File.dirname(__FILE__), "/../test_helper") | |
class ThingsControllerTest < ActionController::TestCase | |
test "action_that_raises_rescued_error does not raise error" do | |
get :action_that_raises_rescued_error | |
assert_response 200 | |
end | |
test "action_that_raises_rescued_error does not raise error with rescue_action_in_public!" do | |
rescue_action_in_public! | |
get :action_that_raises_rescued_error | |
assert_response 200 | |
end | |
test "action_that_raises_un_rescued_error raises error in test" do | |
assert_raises ThingsController::UnRescuedError do | |
get :action_that_raises_un_rescued_error | |
end | |
assert_response 200 # just to see what rails does here - wouldn't do this normally | |
end | |
test "action_that_raises_un_rescued_error raises error in response" do | |
rescue_action_in_public! | |
get :action_that_raises_un_rescued_error | |
assert_response 500 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment