2004-11-23 20:04:44 -05:00
|
|
|
#!/bin/env ruby
|
|
|
|
|
|
|
|
$:.unshift(File.dirname(__FILE__) + "/../lib")
|
|
|
|
|
|
|
|
require 'test/unit'
|
|
|
|
require 'webrick_server'
|
|
|
|
|
|
|
|
class ParseUriTest < Test::Unit::TestCase
|
|
|
|
|
2004-12-15 06:25:35 -05:00
|
|
|
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/'))
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_parse_uri_failures
|
2004-12-15 06:25:35 -05:00
|
|
|
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/')
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|