Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use rspec to test named routes?

Given I have a named route:

map.some_route '/some_routes/:id', :controller => 'some', :action => 'other'

How do I use the routing spec file 'spec/routing/some_routing_spec.rb' to test for that named route?

I've tried this after the "describe SomeRouteController" block and it doesn't work, I get 'undefined method "helper":

describe SomeRouteHelper, 'some routes named routes' do
  it 'should recognize some_route' do
    helper.some_route_path(23).should == '/some_routes/23'
  end
end
like image 313
btelles Avatar asked Nov 19 '09 16:11

btelles


1 Answers

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'
  end
end
like image 157
Baldu Avatar answered Oct 09 '22 09:10

Baldu