Harm Aarts
2007-Nov-02 12:27 UTC
[rspec-users] RSpec, RESTful nested routes and :path_prefix
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!
Nola Stowe
2007-Nov-02 23:56 UTC
[rspec-users] RSpec, RESTful nested routes and :path_prefix
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
Nola Stowe
2007-Nov-02 23:59 UTC
[rspec-users] RSpec, RESTful nested routes and :path_prefix
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. 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
Harm Aarts
2007-Nov-04 14:46 UTC
[rspec-users] RSpec, RESTful nested routes and :path_prefix
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 > ******************************************
Nola Stowe
2007-Nov-04 15:53 UTC
[rspec-users] RSpec, RESTful nested routes and :path_prefix
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 On 11/4/07, Harm Aarts <harm.aarts at innovationfactory.nl> wrote:> 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 > > ****************************************** > > _______________________________________________ > 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
Harm Aarts
2007-Nov-07 16:25 UTC
[rspec-users] RSpec, RESTful nested routes and :path_prefix
I think I did not express myself clear enough. The problem is that in my spec I can not get the ''post'' and ''get'' methods to correctly contact(by lack of a better word) the corresponding actions. I believe this has to do with the fact that I use a :path_prefix. So I would like this:> it "GET ''index'' should be successful" do > get ''index'', :project_id => 1 > response.should be_success > endTo become something like:> it "GET ''index'' should be successful" do > get ''index'', :project_id => , :path_prefix => ''/wiki'' > response.should be_success > endBut that obviously does not work. More importantly I do not believe I should be repeating myself with these path_prefixes. I suspect that RSpec is ignoring the :path_prefix in my routes.rb file. With kind regards, Harm