Dear list,
In the app we are making we have a rout something like this:
map.resources :projects do |projects|
projects.resources :pages, :controller
=>“Wiki::Pages”, :path_prefix => “/projects/:project_id/
wiki”, :name_prefix => “project_wiki_”
end
But I can’t get RSpec(I’m very new to it) to accept this. It keeps
throwing errors:
ActionController::RoutingError in ‘Wiki::PagesController POST
‘create’ should be successful’
No route matches {:action=>“create”, :controller=>“wiki/
pages”, :project_id=>1, :page => {}}
I get why it throws these errors but not how to fix it. The relavant
RSpec:
it “GET ‘create’ should be successful” do
post ‘create’, :project_id => 1, :page => {}
response.should be_success
end
How do I modify the get request properly?
Thanks in advance!
I had a problem when I used:
script/generate rspec_scaffold “admin/users”
it created the specs with the controller name is “admin_user” instead
of “admin/user” which I think should be correct. So I had to go
through all the rspec generated files and change the _ to /
I actually would like to investigate to see if this is a bug and see
if maybe I can write a patch… I would like to contribute! I really
like rspec. 
did you use rspec_scaffolding?
I don’t know if this is the same issue, I would have to see more of
your spec file.
I had a problem when I used:
script/generate rspec_scaffold “admin/users”
it created the specs with the controller name is “admin_user” instead
of “admin/user” which I think should be correct. So I had to go
through all the rspec generated files and change the _ to /
did you use rspec_scaffolding?
I don’t know if this is the same issue, I would have to see more of
your spec file.
I do not believe that is the case here. I used ‘script/genereate
rspec_controller wiki::pages’ and that generated spec files in ‘spec/
controllers/wiki/pages_controller_spec.rb’. So that seemed to be in
order. Excerpt:
require File.dirname(FILE) + ‘/…/…/spec_helper’
describe Wiki::PagesController do
fixtures :projects
#Delete these examples and add some real ones
it “should use Wiki::PagesController” do
controller.should be_an_instance_of(Wiki::PagesController)
end
it “GET ‘index’ should be successful” do
get ‘index’, :project_id => 1
response.should be_success
end
end
Seems OK right? Does RSpec not support nested routes with :path_prefix?
Harm
Hmm… I do do have a controller with path_prefix that works. I wrote
about a problem I am having in this thread,
http://rubyforge.org/pipermail/rspec-users/2007-October/004202.html
They do work, but for some reason I can get one of the named routes to
work.
If you want, email me the full page_controller_spec … and paste