diff --git a/actionpack/test/dispatch/mapper_test.rb b/actionpack/test/dispatch/mapper_test.rb index 10ef00ca503b50ff43fc66463a8a94a210d4d9ed..9049391930d473ca4b63915796014160449337ef 100644 --- a/actionpack/test/dispatch/mapper_test.rb +++ b/actionpack/test/dispatch/mapper_test.rb @@ -38,6 +38,10 @@ def conditions def requirements routes.map { |x| x[2] } end + + def asts + conditions.map { |hash| hash[:parsed_path_info] } + end end def test_initialize @@ -67,7 +71,7 @@ def test_unscoped_formatted mapper.get '/foo', :to => 'posts#index', :as => :main, :format => true assert_equal({:controller=>"posts", :action=>"index"}, fakeset.defaults.first) - assert_equal "/foo.:format", fakeset.conditions.first[:parsed_path_info].to_s + assert_equal "/foo.:format", fakeset.asts.first.to_s end def test_scoped_formatted @@ -78,7 +82,7 @@ def test_scoped_formatted end assert_equal({:controller=>"posts", :action=>"index"}, fakeset.defaults.first) - assert_equal "/foo.:format", fakeset.conditions.first[:parsed_path_info].to_s + assert_equal "/foo.:format", fakeset.asts.first.to_s end def test_random_keys @@ -113,7 +117,7 @@ def test_map_slash fakeset = FakeSet.new mapper = Mapper.new fakeset mapper.get '/', :to => 'posts#index', :as => :main - assert_equal '/', fakeset.conditions.first[:parsed_path_info].to_s + assert_equal '/', fakeset.asts.first.to_s end def test_map_more_slashes @@ -122,14 +126,14 @@ def test_map_more_slashes # FIXME: is this a desired behavior? mapper.get '/one/two/', :to => 'posts#index', :as => :main - assert_equal '/one/two(.:format)', fakeset.conditions.first[:parsed_path_info].to_s + assert_equal '/one/two(.:format)', fakeset.asts.first.to_s end def test_map_wildcard fakeset = FakeSet.new mapper = Mapper.new fakeset mapper.get '/*path', :to => 'pages#show' - assert_equal '/*path(.:format)', fakeset.conditions.first[:parsed_path_info].to_s + assert_equal '/*path(.:format)', fakeset.asts.first.to_s assert_equal(/.+?/, fakeset.requirements.first[:path]) end @@ -137,7 +141,7 @@ def test_map_wildcard_with_other_element fakeset = FakeSet.new mapper = Mapper.new fakeset mapper.get '/*path/foo/:bar', :to => 'pages#show' - assert_equal '/*path/foo/:bar(.:format)', fakeset.conditions.first[:parsed_path_info].to_s + assert_equal '/*path/foo/:bar(.:format)', fakeset.asts.first.to_s assert_equal(/.+?/, fakeset.requirements.first[:path]) end @@ -145,7 +149,7 @@ def test_map_wildcard_with_multiple_wildcard fakeset = FakeSet.new mapper = Mapper.new fakeset mapper.get '/*foo/*bar', :to => 'pages#show' - assert_equal '/*foo/*bar(.:format)', fakeset.conditions.first[:parsed_path_info].to_s + assert_equal '/*foo/*bar(.:format)', fakeset.asts.first.to_s assert_equal(/.+?/, fakeset.requirements.first[:foo]) assert_equal(/.+?/, fakeset.requirements.first[:bar]) end @@ -154,7 +158,7 @@ def test_map_wildcard_with_format_false fakeset = FakeSet.new mapper = Mapper.new fakeset mapper.get '/*path', :to => 'pages#show', :format => false - assert_equal '/*path', fakeset.conditions.first[:parsed_path_info].to_s + assert_equal '/*path', fakeset.asts.first.to_s assert_nil fakeset.requirements.first[:path] end @@ -162,7 +166,7 @@ def test_map_wildcard_with_format_true fakeset = FakeSet.new mapper = Mapper.new fakeset mapper.get '/*path', :to => 'pages#show', :format => true - assert_equal '/*path.:format', fakeset.conditions.first[:parsed_path_info].to_s + assert_equal '/*path.:format', fakeset.asts.first.to_s end def test_raising_helpful_error_on_invalid_arguments