Sha256: 3e58fd735201228afa505535dc0fa3b5cf9336fe5875c153a24db634ceb25d5d

Contents?: true

Size: 1.03 KB

Versions: 24

Compression:

Stored size: 1.03 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/testhelp'

class RedirectHandlerTest < Test::Unit::TestCase

  def setup
    redirect_test_io do
      @server = Mongrel::HttpServer.new('127.0.0.1', 9998)
    end
    @server.run
    @client = Net::HTTP.new('127.0.0.1', 9998)
  end

  def teardown
    @server.stop(true)
  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

24 entries across 24 versions & 5 rubygems

Version Path
phurley-mongrel-1.1.6.1 test/test_redirect_handler.rb
mongrel-maglev--1.1.9.0.1 test/test_redirect_handler.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_redirect_handler.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_redirect_handler.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_redirect_handler.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_redirect_handler.rb
mongrel-1.2.0.pre2-x86-mswin32 test/test_redirect_handler.rb
mongrel-1.2.0.pre2-x86-mingw32 test/test_redirect_handler.rb
mongrel-1.2.0.pre2 test/test_redirect_handler.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_redirect_handler.rb
sho-mongrel-1.1.5 test/test_redirect_handler.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_redirect_handler.rb
mongrel-1.1.3 test/test_redirect_handler.rb
mongrel-1.1.2-java test/test_redirect_handler.rb
mongrel-1.1.3-java test/test_redirect_handler.rb
mongrel-1.1.1 test/test_redirect_handler.rb
mongrel-1.1.2 test/test_redirect_handler.rb
mongrel-1.1.5-x86-mswin32-60 test/test_redirect_handler.rb
mongrel-1.1.4-java test/test_redirect_handler.rb
mongrel-1.1.5-java test/test_redirect_handler.rb