How to use rspec to test named routes? How to use rspec to test named routes? ruby ruby

How to use rspec to test named routes?


If this is in a controller spec, you can call the routing method directly, no helper needed.

describe SomeController do  it 'should recognize ma routes!' do   thing_path(23).should == '/things/23'  endend


In RSpec-Rails 2.7+ you can create a spec/routing directory and put your routing specs in there. See the rspec-rails docs for more info.


there's a nice shoulda matcher for this too:

it { should route(:get, "/users/23").to(:action => "show", :id => 23)

more information on using shoulda matchers with rspec:

https://github.com/thoughtbot/shoulda-matchers