bmizerany / sinatra

(offically at github.com/sinatra/sinatra) Classy web-development dressed in a DSL

This URL has Read+Write access

sinatra / compat / filter_test.rb
100644 31 lines (25 sloc) 0.678 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require File.dirname(__FILE__) + '/helper'
 
context "before filters" do
 
  setup do
    Sinatra.application = nil
    @app = Sinatra.application
  end
 
  specify "should be executed in the order defined" do
    invoked = 0x0
    @app.before { invoked = 0x01 }
    @app.before { invoked |= 0x02 }
    @app.get('/') { 'Hello World' }
    get_it '/'
    should.be.ok
    body.should.be == 'Hello World'
    invoked.should.be == 0x03
  end
 
  specify "should be capable of modifying the request" do
    @app.get('/foo') { 'foo' }
    @app.get('/bar') { 'bar' }
    @app.before { request.path_info = '/bar' }
    get_it '/foo'
    should.be.ok
    body.should.be == 'bar'
  end
 
end