FIX: Tests passing
[sinatra.git] / test / custom_error_test.rb
blob0ba391a7205ebfceb118bde9d5449f5cc9e1c5bf
1 require File.dirname(__FILE__) + '/helper'
3 context "Custom Errors (in general)" do
5   setup do
6     Sinatra.application.options.raise_errors = false
7   end
8   
9   teardown do
10     Sinatra.application.options.raise_errors = true
11   end
13   specify "override the default 404" do
14     
15     get_it '/'
16     should.be.not_found
17     body.should.equal '<h1>Not Found</h1>'
18     
19     error 404 do
20       'Custom 404'
21     end
22     
23     get_it '/'
24     should.be.not_found
25     body.should.equal 'Custom 404'
26     
27   end
28   
29   specify "override the default 500" do
30     
31     get '/' do
32       raise 'asdf'
33     end
34     
35     get_it '/'
36     status.should.equal 500
37     body.should.equal '<h1>Internal Server Error</h1>'
38     
39     
40     error 500 do
41       'Custom 500 for ' + request.env['sinatra.error'].message
42     end
43     
44     get_it '/'
45     
46     get_it '/'
47     status.should.equal 500
48     body.should.equal 'Custom 500 for asdf'
49     
50   end
52 end