Sha256: e9684be7cfd0fd76953d2bd1757b45bb42493ccec60f720e19fe6c9130b5fe7f

Contents?: true

Size: 701 Bytes

Versions: 4

Compression:

Stored size: 701 Bytes

Contents

require 'test/spec'
require 'sinatra/base'
require 'sinatra/test'

describe "Filters" do
  include Sinatra::Test

  it "executes filters in the order defined" do
    count = 0
    mock_app do
      get('/') { 'Hello World' }
      before {
        count.should.be 0
        count = 1
      }
      before {
        count.should.be 1
        count = 2
      }
    end

    get '/'
    should.be.ok
    count.should.be 2
    body.should.equal 'Hello World'
  end

  it "allows filters to modify the request" do
    mock_app {
      get('/foo') { 'foo' }
      get('/bar') { 'bar' }
      before { request.path_info = '/bar' }
    }

    get '/foo'
    should.be.ok
    body.should.be == 'bar'
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
adamwiggins-sinatra-0.8.9 test/filter_test.rb
bmizerany-sinatra-0.9.0 test/filter_test.rb
rtomayko-sinatra-0.8.9 test/filter_test.rb
rtomayko-sinatra-0.9.0 test/filter_test.rb