# Testing routes

**URL:** <https://www.ruby-forum.com/t/testing-routes/140922>\
**Category:** RSpec\
**Created:** [June 19, 2008, 9:04pm UTC](https://www.ruby-forum.com/t/testing-routes/140922 "2008-06-19T21:04:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [June 19, 2008, 9:04pm UTC](https://www.ruby-forum.com/t/testing-routes/140922/1 "2008-06-19T21:04:54Z")

</div>

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 D.

---

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [June 19, 2008, 9:07pm UTC](https://www.ruby-forum.com/t/testing-routes/140922/2 "2008-06-19T21:07:15Z")

</div>

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 D.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> render :text => "Test"
> 
> ```
> 
> This is what I get
> 
> Thanks
> 
> Olivier D.
> 
> * * *
> 
> rspec-users mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [http://rubyforge.org/mailman/listinfo/rspec-users](http://rubyforge.org/mailman/listinfo/rspec-users)

–  
Maurício Linhares  
[http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
(en)  
João Pessoa, PB, +55 83 8867-7208

---

<div class="post-metadata">

**Author:** ![reivilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reivilo](https://www.ruby-forum.com/u/reivilo)\
**Post date:** [June 20, 2008, 3:01pm UTC](https://www.ruby-forum.com/t/testing-routes/140922/3 "2008-06-20T15:01:49Z")

</div>

Hi MaurÃ­cio,

Thanks for your help. It now works.

Olivier

On Thu, Jun 19, 2008 at 3:06 PM, MaurÃ­cio Linhares \<
