Sha256: 66e31b6052692bea9499bb5b317a0d0790355e44c9925bdc62b7cb96611b72a3

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# Copyright (c) 2005 Zed A. Shaw 
# You can redistribute it and/or modify it under the same terms as Ruby.
#
# Additional work donated by contributors.  See http://mongrel.rubyforge.org/attributions.html 
# for more information.

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


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongrel-0.3.13.4 test/test_redirect_handler.rb
mongrel-0.3.13.3 test/test_redirect_handler.rb
mongrel-1.0.1 test/test_redirect_handler.rb
mongrel-1.0 test/test_redirect_handler.rb