Permalink
Browse files

Raise a helpful error message on #mount misuse

  • Loading branch information...
1 parent 89dc481 commit afa68eb1766d8893a1bb79bf989061f3d8f98049 @carllerche carllerche committed Jul 10, 2012
Showing with 13 additions and 0 deletions.
  1. +4 −0 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +9 −0 actionpack/test/dispatch/mapper_test.rb
@@ -430,6 +430,10 @@ def mount(app, options = nil)
if options
path = options.delete(:at)
else
+ unless Hash === app
+ raise ArgumentError, "must be called with mount point"
+ end
+
options = app
app, path = options.find { |k, v| k.respond_to?(:call) }
options.delete(app) if app
@@ -98,6 +98,15 @@ def test_map_wildcard_with_format_true
mapper.get '/*path', :to => 'pages#show', :format => true
assert_equal '/*path.:format', fakeset.conditions.first[:path_info]
end
+
+ def test_raising_helpful_error_on_invalid_arguments
+ fakeset = FakeSet.new
+ mapper = Mapper.new fakeset
+ app = lambda { |env| [200, {}, [""]] }
+ assert_raises ArgumentError do
+ mapper.mount app
+ end
+ end
end
end
end

0 comments on commit afa68eb

Please sign in to comment.