# RSpec, controller testing, and routes.rb

**URL:** <https://www.ruby-forum.com/t/rspec-controller-testing-and-routes-rb/108176>\
**Category:** Rails\
**Created:** [June 29, 2007, 6:20pm UTC](https://www.ruby-forum.com/t/rspec-controller-testing-and-routes-rb/108176 "2007-06-29T18:20:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelleysislander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f6c823/32.png) [@kelleysislander](https://www.ruby-forum.com/u/kelleysislander)\
**Post date:** [June 29, 2007, 6:20pm UTC](https://www.ruby-forum.com/t/rspec-controller-testing-and-routes-rb/108176/1 "2007-06-29T18:20:50Z")

</div>

I didn’t see any forums or lists for RSpec users, so I’m hoping there  
are RSpec users on this list who may be able to help.

I have this in my routes.rb:

map.signup ‘signup/:step’,  
:controller =\> ‘register’,  
:action =\> ‘signup’,  
:step =\> 1

This test in the associated \*.rspec file passes:

it “should assign @step to 1 on a get to 1” do  
get ‘signup’, :step =\> 1  
assigns[:step].should equal(1)  
end

This one fails:

it “should assign @step to 1 on a get to /signup” do  
get ‘signup’  
assigns[:step].should equal(1)  
end

Even though that second test fails, when running under mongrel the  
controller does the expected thing. If I GET /signup, the @step  
variable (which is simply assigned the value of params[:step] by a  
before\_filter) is set to 1 appropriately. It seems that the default  
:step set in the routes.rb works when running in a server, but not  
during testing. I find this odd, since I am able to test my routes  
with route\_for, and they all pass. It seems that during testing, some  
of what routes.rb specifies works, and some doesn’t.

Is this to be expected, or have I managed to break something? It’s  
sort of hard for me to accept that I cannot test behavior of my  
controller that relies on mappings in routes.rb, so I’m guessing I’ve  
got something wrong somewhere.

–  
Bill K.

[http://bkocik.net](http://bkocik.net)

---

<div class="post-metadata">

**Author:** ![kelleysislander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f6c823/32.png) [@kelleysislander](https://www.ruby-forum.com/u/kelleysislander)\
**Post date:** [June 29, 2007, 6:28pm UTC](https://www.ruby-forum.com/t/rspec-controller-testing-and-routes-rb/108176/2 "2007-06-29T18:28:51Z")

</div>

removed\_email\_address@domain.invalid

(cross-posting)

On Jun 29, 2007, at 9:20 AM, Bill K. wrote:

> get ‘signup’  
> of what routes.rb specifies works, and some doesn’t.
> 
> >

Steve R.  
removed\_email\_address@domain.invalid  
[http://www.calicowebdev.com](http://www.calicowebdev.com)
