[rspec-users] Testing routes

Olivier Dupuis olivierdupuis at gmail.com
Fri Jun 20 08:40:20 EDT 2008


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>


More information about the rspec-users mailing list