Juanma Cervera
2009-Mar-02 10:08 UTC
[rspec-users] Changes in specs for routes in rspec 1.1.99.x
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 files) spec/upgrade.sed ===============/route_for/s/id => 1/id => "1"/g /route_for.*create/s/== \(["''].*["'']\)/== {:path => \1, :method => :post}/ /route_for.*update/s/== \(["''].*["'']\)/== {:path => \1, :method => :put}/ /route_for.*destroy/s/== \(["''].*["'']\)/== {:path => \1, :method => :delete}/ and spec/upgrade ===========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. Juanma -- Posted via http://www.ruby-forum.com/.
Jeremy Kleindl
2009-Mar-02 22:13 UTC
[rspec-users] Changes in specs for routes in rspec 1.1.99.x
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... On Mar 2, 4:08 am, Juanma Cervera <li... at ruby-forum.com> wrote:> 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 > files) > > spec/upgrade.sed > ===============> /route_for/s/id => 1/id => "1"/g > /route_for.*create/s/== \(["''].*["'']\)/== {:path => \1, :method => > :post}/ > /route_for.*update/s/== \(["''].*["'']\)/== {:path => \1, :method => > :put}/ > /route_for.*destroy/s/== \(["''].*["'']\)/== {:path => \1, :method => > :delete}/ > > and > spec/upgrade > ===========> 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. > Juanma > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
Jeremy Kleindl
2009-Mar-02 22:22 UTC
[rspec-users] Changes in specs for routes in rspec 1.1.99.x
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. On Mar 2, 4:08 am, Juanma Cervera <li... at ruby-forum.com> wrote:> 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 > files) > > spec/upgrade.sed > ===============> /route_for/s/id => 1/id => "1"/g > /route_for.*create/s/== \(["''].*["'']\)/== {:path => \1, :method => > :post}/ > /route_for.*update/s/== \(["''].*["'']\)/== {:path => \1, :method => > :put}/ > /route_for.*destroy/s/== \(["''].*["'']\)/== {:path => \1, :method => > :delete}/ > > and > spec/upgrade > ===========> 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. > Juanma > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users