Notify user of error if DSL error
[sinatra.git] / test / custom_error_test.rb
blob6bd3f3ec8eb7230ca711ced409c62df50b2b4eb5
1 require File.dirname(__FILE__) + '/helper'
3 context "Custom Errors (in general)" do
5   specify "override the default 404" do
6     
7     get_it '/'
8     should.be.not_found
9     body.should.equal '<h1>Not Found</h1>'
10     
11     error 404 do
12       'Custom 404'
13     end
14     
15     get_it '/'
16     should.be.not_found
17     body.should.equal 'Custom 404'
18     
19   end
20   
21   specify "override the default 500" do
22     
23     get '/' do
24       raise 'asdf'
25     end
26     
27     get_it '/'
28     status.should.equal 500
29     body.should.equal '<h1>Internal Server Error</h1>'
30     
31     
32     error 500 do
33       'Custom 500 for ' + request.env['sinatra.error'].message
34     end
35     
36     get_it '/'
37     
38     get_it '/'
39     status.should.equal 500
40     body.should.equal 'Custom 500 for asdf'
41     
42   end
44 end