Notify user of error if DSL error
[sinatra.git] / test / app_test.rb
bloba6d6a99731639dd7bf2e9aa8b34c1bd48cd10a82
1 require File.dirname(__FILE__) + '/helper'
3 context "Sinatra" do
4   
5   setup do
6     Sinatra.application = nil
7   end
8   
9   specify "handles events" do
10     get '/:name' do
11       'Hello ' + params[:name]
12     end
13     
14     get_it '/Blake'
15     
16     should.be.ok
17     body.should.equal 'Hello Blake'
18   end
19   
20   specify "follows redirects" do
21     get '/' do
22       redirect '/blake'
23     end
24     
25     get '/blake' do
26       'Mizerany'
27     end
28     
29     get_it '/'
30     should.be.redirection
31     body.should.equal ''
32     
33     follow!
34     should.be.ok
35     body.should.equal 'Mizerany'
36   end
37   
38   specify "body sets content and ends event" do
39     
40     Sinatra::EventContext.any_instance.expects(:foo).never
41     
42     get '/set_body' do
43       stop 'Hello!'
44       stop 'World!'
45       foo
46     end
47     
48     get_it '/set_body'
49     
50     should.be.ok
51     body.should.equal 'Hello!'
52     
53   end
54       
55 end