Adds failing test for after filters

This commit is contained in:
Nathan Esquenazi 2013-03-13 11:39:12 -07:00
parent 13f8796771
commit 6f315b619c
1 changed files with 29 additions and 0 deletions

View File

@ -434,4 +434,33 @@ class AfterFilterTest < Test::Unit::TestCase
get('/', {}, { 'HTTP_ACCEPT' => '*/*' })
assert_body 'txt'
end
it 'can catch exceptions in after filters and handle them properly' do
doodle = ''
mock_app do
after do
doodle += ' and after'
raise StandardError, "after"
end
get :foo do
doodle = 'Been now'
raise StandardError, "now"
end
get :index do
doodle = 'Been now'
end
error 500 do
"We broke #{env['sinatra.error'].message}"
end
end
get '/foo'
assert_equal 'We broke now', body
assert_equal 'Been now', doodle
doodle = ''
get '/'
assert_equal 'We broke after', body
assert_equal 'Been now and after', doodle
end
end