1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/test/custom_error_test.rb
2008-02-24 16:43:39 -08:00

55 lines
940 B
Ruby

require File.dirname(__FILE__) + '/helper'
context "Custom Errors (in general)" do
setup do
Sinatra.application = nil
end
specify "override the default 404" do
get_it '/'
should.be.not_found
body.should.equal '<h1>Not Found</h1>'
error Sinatra::NotFound do
'Custom 404'
end
get_it '/'
should.be.not_found
body.should.equal 'Custom 404'
end
specify "override the default 500" do
Sinatra.application.options.raise_errors = false
get '/' do
raise 'asdf'
end
get_it '/'
status.should.equal 500
body.should.equal '<h1>Internal Server Error</h1>'
error do
'Custom 500 for ' + request.env['sinatra.error'].message
end
get_it '/'
get_it '/'
status.should.equal 500
body.should.equal 'Custom 500 for asdf'
Sinatra.application.options.raise_errors = true
end
end