aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-12-22 12:53:14 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-12-22 12:53:14 -0700
commitde6e92fe53ca8760ca3bb16ece64e152eb15c8ef (patch)
treed257d8062adf4a051546811cdd1fe64e9fad66f8
parent62456a35f15bb3a9c8883fac2c510480f3f276b7 (diff)
downloadrails-de6e92fe53ca8760ca3bb16ece64e152eb15c8ef.tar.gz
rails-de6e92fe53ca8760ca3bb16ece64e152eb15c8ef.tar.bz2
rails-de6e92fe53ca8760ca3bb16ece64e152eb15c8ef.zip
refactoring routing tests
-rw-r--r--actionpack/test/controller/routing_test.rb53
1 files changed, 19 insertions, 34 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index a931222bbc..d6ae9909b8 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -78,7 +78,19 @@ class LegacyRouteSetTests < Test::Unit::TestCase
attr_reader :rs
def setup
- @rs = ::ActionDispatch::Routing::RouteSet.new
+ @rs = ::ActionDispatch::Routing::RouteSet.new
+ @response = nil
+ end
+
+ def get(uri_or_host, path = nil, port = nil)
+ host = uri_or_host.host unless path
+ path ||= uri_or_host.path
+
+ params = {'PATH_INFO' => path,
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_HOST' => host}
+
+ @rs.call(params)[2]
end
def test_regexp_precidence
@@ -90,17 +102,8 @@ class LegacyRouteSetTests < Test::Unit::TestCase
match '/whois/:id', :to => lambda { |env| [200, {}, 'id'] }
end
- body = @rs.call({'PATH_INFO' => '/whois/example.org',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_HOST' => 'www.example.org'})[2]
-
- assert_equal 'regexp', body
-
- body = @rs.call({'PATH_INFO' => '/whois/123',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_HOST' => 'clients.example.org'})[2]
-
- assert_equal 'id', body
+ assert_equal 'regexp', get(URI('http://example.org/whois/example.org'))
+ assert_equal 'id', get(URI('http://example.org/whois/123'))
end
def test_class_and_lambda_constraints
@@ -117,17 +120,8 @@ class LegacyRouteSetTests < Test::Unit::TestCase
:to => lambda { |env| [200, {}, 'clients'] }
end
- body = @rs.call({'PATH_INFO' => '/',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_HOST' => 'www.example.org'})[2]
-
- assert_equal 'default', body
-
- body = @rs.call({'PATH_INFO' => '/',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_HOST' => 'clients.example.org'})[2]
-
- assert_equal 'clients', body
+ assert_equal 'default', get(URI('http://www.example.org/'))
+ assert_equal 'clients', get(URI('http://clients.example.org/'))
end
def test_lambda_constraints
@@ -141,17 +135,8 @@ class LegacyRouteSetTests < Test::Unit::TestCase
:to => lambda { |env| [200, {}, 'clients'] }
end
- body = @rs.call({'PATH_INFO' => '/',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_HOST' => 'www.example.org'})[2]
-
- assert_equal 'default', body
-
- body = @rs.call({'PATH_INFO' => '/',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_HOST' => 'clients.example.org'})[2]
-
- assert_equal 'clients', body
+ assert_equal 'default', get(URI('http://www.example.org/'))
+ assert_equal 'clients', get(URI('http://clients.example.org/'))
end
def test_draw_with_block_arity_one_raises