diff options
author | yui-knk <spiketeika@gmail.com> | 2015-11-22 19:22:36 +0900 |
---|---|---|
committer | yui-knk <spiketeika@gmail.com> | 2015-11-28 10:50:11 +0900 |
commit | f8f7e66f5fe393136755ebd00c49cf4081a5dc12 (patch) | |
tree | 3fbba9e5bf0d51f27507dc3d14be93740c1d5f86 /actionpack/lib/action_dispatch | |
parent | 4596c1a31902806a15c970a0e210942912b139b6 (diff) | |
download | rails-f8f7e66f5fe393136755ebd00c49cf4081a5dc12.tar.gz rails-f8f7e66f5fe393136755ebd00c49cf4081a5dc12.tar.bz2 rails-f8f7e66f5fe393136755ebd00c49cf4081a5dc12.zip |
Brush up errors of `ActionDispatch::Routing::Mapper#mount`
* Integrate to raise `ArgumentError`
* Detailed error message when `path` is not defined
* Add a test case, invalid rack app is passed
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 7c0404ca62..e676c837b4 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -600,17 +600,20 @@ module ActionDispatch def mount(app, options = nil) if options path = options.delete(:at) - else - unless Hash === app - raise ArgumentError, "must be called with mount point" - end - + elsif Hash === app options = app app, path = options.find { |k, _| k.respond_to?(:call) } options.delete(app) if app end - raise "A rack application must be specified" unless path + raise ArgumentError, "A rack application must be specified" unless app.respond_to?(:call) + raise ArgumentError, <<-MSG.strip_heredoc unless path + Must be called with mount point + + mount SomeRackApp, at: "some_route" + or + mount(SomeRackApp => "some_route") + MSG rails_app = rails_app? app options[:as] ||= app_name(app, rails_app) |