[rspec-users] undefined method `route_for

David Chelimsky dchelimsky at gmail.com
Wed Nov 11 07:46:52 EST 2009

On Wed, Nov 11, 2009 at 1:42 AM, Amit Kulkarni <lists at ruby-forum.com> wrote:

> Thanks David for the information but still i am getting the same error.
> What i have done is:
> I have home controller.
> now i am writing route scenarios in home_controller_spec.rb which is
> under spec/controllers directory
> I tried your code which looks like as
> describe "route generation", :type => :HomeController do
>     it "should map { :controller => 'home', :action => 'index' } to
> /home" do
>      route_for(:controller => 'home', :action => 'index').should ==
> '/home'
>    end
>    it "should map { :controller => 'home' } RESTfully" do
>      params_from( :get, '/home' ).should == { :controller => 'home',
> :action => 'index' }
>    end
>  end
> But it is not working,i know i am missing something.
> Also can you explain the first point?
> Can you tell me up what i need to add to get it running atleast :-)

If the spec is in spec/controllers/home_controller_spec.rb, you don't need
the :type argument, so just get rid of that and you should be fine. If this
still doesn't work, please post the command you are using as well.

For future reference, if you put a controller or routing spec in another
directory, then you do need the :type argument, but :type means the type of
spec, not the type of controller:

describe "route generation", :type => :controller do

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091111/55d04a0a/attachment.html>

More information about the rspec-users mailing list