diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2012-05-15 04:28:10 +0200 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2012-05-15 04:28:10 +0200 |
commit | 0d3172c4e42d547fa41007a3c3895e240110a58d (patch) | |
tree | 9fee5d6cbd4bd20587c21a9ddc6e763b0eaa41e5 /actionpack/test | |
parent | 2c0add7103e967a7de2df42675eb49e093327c58 (diff) | |
download | rails-0d3172c4e42d547fa41007a3c3895e240110a58d.tar.gz rails-0d3172c4e42d547fa41007a3c3895e240110a58d.tar.bz2 rails-0d3172c4e42d547fa41007a3c3895e240110a58d.zip |
add tests and external file backtrace for Routing::Mapper#draw
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 49 | ||||
-rw-r--r-- | actionpack/test/fixtures/routes/bogus.rb | 1 | ||||
-rw-r--r-- | actionpack/test/fixtures/routes/external.rb | 1 |
3 files changed, 51 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 3cec816f1c..1a8f40037f 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -2324,6 +2324,55 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest end end +class TestDrawExternalFile < ActionDispatch::IntegrationTest + class ExternalController < ActionController::Base + def index + render :text => "external#index" + end + end + + DRAW_PATH = Pathname.new(File.expand_path('../../fixtures/routes', __FILE__)) + + DefaultScopeRoutes = ActionDispatch::Routing::RouteSet.new.tap do |app| + app.draw_paths << DRAW_PATH + end + + def app + DefaultScopeRoutes + end + + def test_draw_external_file + DefaultScopeRoutes.draw do + scope :module => 'test_draw_external_file' do + draw :external + end + end + + get '/external' + assert_equal "external#index", @response.body + end + + def test_draw_nonexistent_file + exception = assert_raise ArgumentError do + DefaultScopeRoutes.draw do + draw :nonexistent + end + end + assert_match 'Your router tried to #draw the external file nonexistent.rb', exception.message + assert_match DRAW_PATH.to_s, exception.message + end + + def test_draw_bogus_file + exception = assert_raise NoMethodError do + DefaultScopeRoutes.draw do + draw :bogus + end + end + assert_match "undefined method `wrong'", exception.message + assert_match 'test/fixtures/routes/bogus.rb:1', exception.backtrace.first + end +end + class TestDefaultScope < ActionDispatch::IntegrationTest module ::Blog class PostsController < ActionController::Base diff --git a/actionpack/test/fixtures/routes/bogus.rb b/actionpack/test/fixtures/routes/bogus.rb new file mode 100644 index 0000000000..41fbf0cd64 --- /dev/null +++ b/actionpack/test/fixtures/routes/bogus.rb @@ -0,0 +1 @@ +wrong :route diff --git a/actionpack/test/fixtures/routes/external.rb b/actionpack/test/fixtures/routes/external.rb new file mode 100644 index 0000000000..d103c39f53 --- /dev/null +++ b/actionpack/test/fixtures/routes/external.rb @@ -0,0 +1 @@ +get '/external' => 'external#index' |