[rspec-users] RSpec, RESTful nested routes and :path_prefix

Harm Aarts harm.aarts at innovationfactory.nl
Sun Nov 4 09:46:13 EST 2007


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

> ------------------------------
>
> Message: 11
> Date: Fri, 2 Nov 2007 19:56:22 -0400
> From: "Nola Stowe" <mrnicksgirl at gmail.com>
> Subject: Re: [rspec-users] RSpec, RESTful nested routes and
> 	:path_prefix
> To: rspec-users <rspec-users at rubyforge.org>
> Message-ID:
> 	<43e95380711021656y4369ecb2wf3053d30b5556c51 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> 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.
>
>
>
> On 11/2/07, Harm Aarts <harm.aarts at innovationfactory.nl> wrote:
>> 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!
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
>
>
> -- 
> http://rubygeek.com - my blog featuring: Ruby, PHP and Perl
> http://DevChix.com - boys can't have all the fun
>
>
> ------------------------------
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
> End of rspec-users Digest, Vol 17, Issue 3
> ******************************************



More information about the rspec-users mailing list