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

   def do_get
     get :new        # doesn't work
     #get 'new'       # doesn't work either
     #get '/wiki/new' # doesn't work either

   it 'should succeed' do
     response.should be_success


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?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs