This project is archived and is in readonly mode.
cannot test a controller action for a route defined with match
-
EmmanuelOga
Forgot to add the test unit output, here it is:
▸ bundle show rails /home/emmanuel/.rvm/gems/ruby-1.8.7-p174/gems/rails-3.0.0esponse :success ▸ ruby -I test/ test/functional/public_listings_controller_test.rb Loaded suite test/functional/public_listings_controller_test Started E Finished in 0.113132 seconds. 1) Error: test_should_get_a_feed(Public::ListingsControllerTest): ActionController::RoutingError: No route matches {:action=>"feed", :format=>"xml", :controller=>"public/listings", :service=>"google_base"} test/functional/public_listings_controller_test.rb:6:in `test_should_get_a_feed' 1 tests, 0 assertions, 0 failures, 1 errors -
Andrew White
- Milestone cleared.
- State changed from new to open
- Assigned user set to Andrew White
- Importance changed from to Low
The thing that's making your test fail is the leading slash on the controller spec - remove that and the test will pass. However your route could do with a little more tweaking - look at the output of
rake routes:feed /feed/:service(.xml)(.:format) {:format=>:xml, :action=>"feed", :controller=>"public/listings"}As you can see you have a format parameter and an optional .xml segment. I'm assuming that you want to enforce xml urls in which case you need to turn off the automatic format parameter and add in a default for it:
match "/feed/:service.xml" => "public/listings#feed", :format => false, :defaults => { :format => "xml" }, :as => :feedwhich gives the following
rake routesoutput:feed /feed/:service.xml {:format=>"xml", :action=>"feed", :controller=>"public/listings"}I'll mark it as open because we probably want to clean up the controller automatically.
-
Repository
- State changed from open to resolved
(from [013ed1c0503e59dc8f1cfff1bd00d0e579c604a1]) Remove leading slash from controller [#5651 cannot test a controller action for a route defined with match state:resolved] http://github.com/rails/rails/commit/013ed1c0503e59dc8f1cfff1bd00d0...
-
Repository
(from [301462c89b2f21f399ff538d821d09258836dafa]) Remove leading slash from controller [#5651 cannot test a controller action for a route defined with match state:resolved] http://github.com/rails/rails/commit/301462c89b2f21f399ff538d821d09...
-
Repository
(from [0bffd7d933a46df958c3e6bae1d9871aca515a12]) Raise ArgumentError instead of normalizing controller name when there is a leading slash [#5651 cannot test a controller action for a route defined with match state:resolved] http://github.com/rails/rails/commit/0bffd7d933a46df958c3e6bae1d987...
-
Repository
(from [b79a782a05df50028c04b4336d45875352e89d12]) Raise ArgumentError instead of normalizing controller name when there is a leading slash [#5651 cannot test a controller action for a route defined with match state:resolved] http://github.com/rails/rails/commit/b79a782a05df50028c04b4336d4587...