Register now and start sharing your code snippets.
-->

How to test Rails routing with RSpec

Ruby posted 3 months ago by christian

   1  route_for(:controller => 'categories', :action => 'show', :permalink => ['one', 'two', 'three']).should.equal '/one/two/three'
   2  route_for(:controller => 'categories', :action => 'index').should.equal '/'
   3        
   4  params_from(:get, "/").should.equal {:controller => "categories", :action => "index"}
   5  params_from(:get, "/something/").should.equal {:controller => "categories", :action => "show", :permalink => ["something"]}

The test_spec_on_rails plugin also allow you to test routing and much more, see the docs for more information.

Tagged testing, rspec, routing, routes