Hello,
I''m creating a REST resource with the following map
*map.resources :books, :member => { :prices => :get }
*
I would like to test the books controller
*class BooksController < ApplicationController
def prices
render :text => "Test"
end
end*
I have the following test
*it "should render properly when getting /books/:id/prices" do
get "prices"
response.should be_success
end*
This is what I get
*ActionController::RoutingError in ''BooksController requesting
/books/:id/prices
using GET should render properly when getting /books/:id/prices''
No route matches {:controller=>"books",
:action=>"prices"}
./spec/controllers/books_controller_spec.rb:5:*
I''ve tried many different alternatives for get, but they always end up
with
the same error. I''m surely missing something. Any help would be
appreciated.
Thanks
Olivier Dupuis
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20080619/dc670b8d/attachment-0001.html>
Try this:
it "should render properly when getting /books/:id/prices" do
get "prices", :id => ''0''
response.should be_success
end
Or even better (or what i think you wanted to do):
map.resources :books, :collection => { :prices => :get }
And your spec won''t be changed.
On Thu, Jun 19, 2008 at 4:04 PM, Olivier Dupuis <olivierdupuis at
gmail.com> wrote:> Hello,
>
> I''m creating a REST resource with the following map
>
> map.resources :books, :member => { :prices => :get }
>
> I would like to test the books controller
>
> class BooksController < ApplicationController
> def prices
> render :text => "Test"
> end
> end
>
> I have the following test
>
> it "should render properly when getting /books/:id/prices" do
> get "prices"
> response.should be_success
> end
>
> This is what I get
>
> ActionController::RoutingError in ''BooksController requesting
> /books/:id/prices
> using GET should render properly when getting /books/:id/prices''
> No route matches {:controller=>"books",
:action=>"prices"}
> ./spec/controllers/books_controller_spec.rb:5:
>
> I''ve tried many different alternatives for get, but they always
end up with
> the same error. I''m surely missing something. Any help would be
> appreciated.
>
> Thanks
>
> Olivier Dupuis
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
--
Maur?cio Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)
Jo?o Pessoa, PB, +55 83 8867-7208
Hi Maur?cio, Thanks for your help. It now works. Olivier On Thu, Jun 19, 2008 at 3:06 PM, Maur?cio Linhares < mauricio.linhares at gmail.com> wrote:> Try this: > > it "should render properly when getting /books/:id/prices" do > get "prices", :id => ''0'' > response.should be_success > end > > Or even better (or what i think you wanted to do): > > map.resources :books, :collection => { :prices => :get } > > And your spec won''t be changed. > > On Thu, Jun 19, 2008 at 4:04 PM, Olivier Dupuis <olivierdupuis at gmail.com> > wrote: > > Hello, > > > > I''m creating a REST resource with the following map > > > > map.resources :books, :member => { :prices => :get } > > > > I would like to test the books controller > > > > class BooksController < ApplicationController > > def prices > > render :text => "Test" > > end > > end > > > > I have the following test > > > > it "should render properly when getting /books/:id/prices" do > > get "prices" > > response.should be_success > > end > > > > This is what I get > > > > ActionController::RoutingError in ''BooksController requesting > > /books/:id/prices > > using GET should render properly when getting /books/:id/prices'' > > No route matches {:controller=>"books", :action=>"prices"} > > ./spec/controllers/books_controller_spec.rb:5: > > > > I''ve tried many different alternatives for get, but they always end up > with > > the same error. I''m surely missing something. Any help would be > > appreciated. > > > > Thanks > > > > Olivier Dupuis > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Maur?cio Linhares > http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) > Jo?o Pessoa, PB, +55 83 8867-7208 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080620/6baec712/attachment.html>