mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
661090eb53
I changed the ".should." style to use "fail" when we converted to test/unit style but I'd rather use asserts here.
35 lines
663 B
Ruby
35 lines
663 B
Ruby
require File.dirname(__FILE__) + '/helper'
|
|
|
|
describe "Filters" do
|
|
it "executes filters in the order defined" do
|
|
count = 0
|
|
mock_app do
|
|
get('/') { 'Hello World' }
|
|
before {
|
|
assert_equal 0, count
|
|
count = 1
|
|
}
|
|
before {
|
|
assert_equal 1, count
|
|
count = 2
|
|
}
|
|
end
|
|
|
|
get '/'
|
|
assert ok?
|
|
assert_equal 2, count
|
|
assert_equal 'Hello World', body
|
|
end
|
|
|
|
it "allows filters to modify the request" do
|
|
mock_app {
|
|
get('/foo') { 'foo' }
|
|
get('/bar') { 'bar' }
|
|
before { request.path_info = '/bar' }
|
|
}
|
|
|
|
get '/foo'
|
|
assert ok?
|
|
assert_equal 'bar', body
|
|
end
|
|
end
|