1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/webrick_dispatcher_test.rb

28 lines
1.1 KiB
Ruby
Raw Normal View History

#!/bin/env ruby
$:.unshift(File.dirname(__FILE__) + "/../lib")
require 'test/unit'
require 'webrick_server'
class ParseUriTest < Test::Unit::TestCase
def test_parse_uri_proper_behavior
assert_equal({:id=>"1", :controller=>"forum", :action=>"index"}, DispatchServlet.parse_uri('/forum/index/1'))
assert_equal({:controller=>"forum", :action=>"index"}, DispatchServlet.parse_uri('/forum'))
assert_equal({:controller=>"forum", :action=>"index"}, DispatchServlet.parse_uri('/forum/index'))
assert_equal({:controller=>"forum", :action=>"index"}, DispatchServlet.parse_uri('/forum/'))
assert_equal({:action=>"index", :module=>"admin", :controller=>"forum"}, DispatchServlet.parse_uri('/admin/forum/'))
end
def test_parse_uri_failures
assert_equal false, DispatchServlet.parse_uri('/forum/index/1/')
assert_equal false, DispatchServlet.parse_uri('/')
assert_equal false, DispatchServlet.parse_uri('a')
assert_equal false, DispatchServlet.parse_uri('/forum//')
assert_equal false, DispatchServlet.parse_uri('/+forum/')
assert_equal false, DispatchServlet.parse_uri('forum/')
end
end