Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test for too many args

  • Loading branch information...
commit 664f3ad272ae9615f5db84bc026ce580774410b7 1 parent 0c0f474
Joshua Hull authored
Showing with 9 additions and 1 deletion.
  1. +2 −0  lib/http_router.rb
  2. +7 −1 test/test_misc.rb
2  lib/http_router.rb
View
@@ -24,6 +24,8 @@ class HttpRouter
DoubleCompileError = Class.new(RuntimeError)
# Raised an invalid request value is used
InvalidRequestValueError = Class.new(RuntimeError)
+ # Raised when there are extra parameters passed in to #url
+ TooManyParametersException = Class.new(RuntimeError)
# Creates a new HttpRouter.
# Can be called with either <tt>HttpRouter.new(proc{|env| ... }, { .. options .. })</tt> or with the first argument omitted.
8 test/test_misc.rb
View
@@ -64,7 +64,7 @@ def test_regex_generation
assert_equal '/test/var', r.url(:route, "var")
end
- def test_regex_generation
+ def test_too_many_params
r = HttpRouter.new
r.add(%r|/test/.*|, :path_for_generation => '/test/:variable').name(:route).default_destination
assert_equal '/test/var', r.url(:route, "var")
@@ -72,6 +72,12 @@ def test_regex_generation
assert_raises(HttpRouter::InvalidRouteException) { r.url(:route) }
end
+ def test_too_many_args
+ r = HttpRouter.new
+ r.add('/').name(:route).default_destination
+ assert_raises(HttpRouter::TooManyParametersException) { r.url(:route, "hi") }
+ end
+
def test_public_interface
methods = HttpRouter.public_instance_methods.map(&:to_sym)
assert methods.include?(:url_mount)
Please sign in to comment.
Something went wrong with that request. Please try again.