Wincent Colaiuta
2008-Mar-26 21:34 UTC
[rspec-users] How to spec controller whose route has a different name?
Perhaps I am missing something extremely obvious, but I am unable to get my specs to work for an ArticlesController which is accessed using URLs like "/wiki/foo". Here''s the corresponding line from config/routes.rb: map.resources :wiki, :controller => ''articles'' This is Rails 2.0.2, but in the next release that will be: map.resources :articles, :as => :wiki And here is a very short excerpt from the specs: describe ArticlesController do describe ''GET /wiki/new'' do before do @article = mock_model Article Article.stub!(:new).and_return(@article) end def do_get get :new # doesn''t work #get ''new'' # doesn''t work either #get ''/wiki/new'' # doesn''t work either end it ''should succeed'' do do_get response.should be_success end end end In specs where the controller uses totally "normal" routing, RSpec seems to correctly infer that when I "describe ThingController" and then do "get :new" then I am talking about doing a GET of "/thing/ new". But that doesn''t seem to be happening in this case (all the specs fail) and I can''t seem to figure out how to make it work. I tried setting an explicit controller_name but it didn''t help. Any suggestions? Cheers, Wincent