1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/test/filter_test.rb
Ryan Tomayko 661090eb53 Allow assertions in mock_app request context
I changed the ".should." style to use "fail" when we
converted to test/unit style but I'd rather use asserts
here.
2009-01-15 04:18:18 -08:00

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