Forum: RSpec Changes in specs for routes in rspec 1.1.99.x

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F1e1789ff9e7fc3032fa6cf15382a1e8?d=identicon&s=25 Juanma Cervera (jmcervera)
on 2009-03-02 11:08
Trying the next release of rspec, I have had to make changes in the
existing specs for routing.
I have written an script with sed that makes this automatically (two

/route_for/s/id => 1/id => "1"/g
/route_for.*create/s/== \(["'].*["']\)/== {:path => \1, :method =>
/route_for.*update/s/== \(["'].*["']\)/== {:path => \1, :method =>
/route_for.*destroy/s/== \(["'].*["']\)/== {:path => \1, :method =>

for f in `find controllers -name "*routing*rb" -type f`; do sed -i -f
upgrade.sed $f; done

You shoud make this file executable and run it

I hope this helps somebody.
0fcfdbf7b91c277f443ccc3720716057?d=identicon&s=25 Jeremy Kleindl (Guest)
on 2009-03-03 15:26
(Received via mailing list)
Thank you for posting this.
Is this a script to replace/add arguments to the route_for methods in
my current controller routing specs?
Will the changes this script affects fix the errors I get when running
specs like " route_for(_whatever_)should == '/foo/1' " on :update
and :destroy actions generating a :show route?

I've tried adding a :method argument and passing :put and :delete - no
go on these assuring the correct routes so far. I'm off to read the
rspec source to figure out WTF changed...
0fcfdbf7b91c277f443ccc3720716057?d=identicon&s=25 Jeremy Kleindl (Guest)
on 2009-03-03 15:48
(Received via mailing list)
GAh! easy one - I was adding the method argument to the 'route_for()'
instead of the 'should ==' hash it compares the generated output with.
And now I see how the script you made takes the single string argument
from the old style and drops it into a hash that includes the restful
method name.
Thank you for providing the clue I needed to get the correct syntax.
This topic is locked and can not be replied to.