mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
217b2e746b
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@250 19e92222-5c0b-0410-8929-a290d50e31e9
40 lines
853 B
Ruby
40 lines
853 B
Ruby
require 'test/unit'
|
|
require 'mongrel'
|
|
require 'net/http'
|
|
require 'uri'
|
|
require 'timeout'
|
|
|
|
class RedirectHandlerTest < Test::Unit::TestCase
|
|
|
|
def setup
|
|
@server = Mongrel::HttpServer.new('127.0.0.1', 9998)
|
|
@server.run
|
|
@client = Net::HTTP.new('127.0.0.1', 9998)
|
|
end
|
|
|
|
def teardown
|
|
@server.stop
|
|
end
|
|
|
|
def test_simple_redirect
|
|
tester = Mongrel::RedirectHandler.new('/yo')
|
|
@server.register("/test", tester)
|
|
|
|
sleep(1)
|
|
res = @client.request_get('/test')
|
|
assert res != nil, "Didn't get a response"
|
|
assert_equal ['/yo'], res.get_fields('Location')
|
|
end
|
|
|
|
def test_rewrite
|
|
tester = Mongrel::RedirectHandler.new(/(\w+)/, '+\1+')
|
|
@server.register("/test", tester)
|
|
|
|
sleep(1)
|
|
res = @client.request_get('/test/something')
|
|
assert_equal ['/+test+/+something+'], res.get_fields('Location')
|
|
end
|
|
|
|
end
|
|
|
|
|