Skip to content

Commit

Permalink
add some tests, yay!
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Feb 22, 2012
1 parent 36d9fd7 commit a328f2f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions actionpack/test/routing/helper_test.rb
@@ -0,0 +1,31 @@
require 'abstract_unit'

module ActionDispatch
module Routing
class HelperTest < ActiveSupport::TestCase
class Duck
def to_param
nil
end
end

def test_exception
rs = ::ActionDispatch::Routing::RouteSet.new
rs.draw do
resources :ducks do
member do
get :pond
end
end
end

x = Class.new {
include rs.url_helpers
}
assert_raises ActionController::RoutingError do
x.new.pond_duck_path Duck.new
end
end
end
end
end

4 comments on commit a328f2f

@amatsuda
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why but I just found that running this test alone fails.

1) Failure:
test_exception(ActionDispatch::Routing::HelperTest) [.../rails/actionpack/test/routing/helper_test.rb:25]:
ActionController::RoutingError expected but nothing was raised.

@amatsuda
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turned out that this test was not executed via rake test. Including test/routing/**/*_test.rb in Rakefile reveals the error.

diff --git a/actionpack/Rakefile b/actionpack/Rakefile
index ba7956c..7b9a279 100644
--- a/actionpack/Rakefile
+++ b/actionpack/Rakefile
@@ -15,7 +15,7 @@ Rake::TestTask.new(:test_action_pack) do |t|

   # make sure we include the tests in alphabetical order as on some systems
   # this will not happen automatically and the tests (as a whole) will error
-  t.test_files = Dir.glob('test/{abstract,controller,dispatch,template,assertions,journey}/**/*_test.rb').sort
+  t.test_files = Dir.glob('test/{abstract,controller,dispatch,template,assertions,journey,routing}/**/*_test.rb').sort

The test expects x.new.pond_duck_path Duck.new to raise an ActionController::RoutingError but in fact it returns "/ducks//pond"

@tenderlove, which is your intended behaviour?

@pixeltrix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amatsuda fixed here: 74722d6

@amatsuda
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.