1 require File.dirname(__FILE__) + '/helper'
3 context "Dispatching" do
5 include Sinatra::Test::Methods
8 Sinatra.config[:raise_errors] = false
10 Sinatra.config[:raise_errors] = true
17 specify "should return the correct block" do
22 result = Sinatra.determine_route(:get, '/')
23 result.block.should.be r.block
26 specify "should return custom 404" do
27 Sinatra.routes[404] = r = Proc.new { 'custom 404' }
29 result = Sinatra.determine_route(:get, '/')
33 specify "should return standard 404" do
35 body.should.equal '<h1>Not Found</h1>'
38 specify "should give custom 500 if error when called" do
39 Sinatra.routes[500] = r = Proc.new { 'custom 500' }
49 body.should.equal 'custom 500'
52 specify "should give standard 500 if error when called" do
61 body.should.match(/^asdf/)
64 specify "should run in a context" do
65 Sinatra::EventContext.any_instance.expects(:foo).returns 'in foo'
72 body.should.equal 'in foo'
75 specify "has access to the request" do
83 body.should.equal '/blake'
87 specify "has DSLified methods for response" do
95 body.should.equal "uh oh"
96 status.should.equal 555
101 context "An Event in test mode" do
103 include Sinatra::Test::Methods
109 specify "should raise errors to top" do
114 lambda { get_it '/' }.should.raise(RuntimeError)