#488 open
Mike Vincent

Routes requiring additional parameters fail to generate in view specs

Reported by Mike Vincent | August 7th, 2008 @ 10:17 PM | in No-Milestone-Assigned

I have a helper which creates a form and was getting route generation errors in the view specs using the helper.

The problem seemed to stem from a few factors..

  • It's a nested resource
  • url_for, from a form in this case, wasn't explicitly given a url, rather it was expected to generate it from the existing parameters.
  • rspec explicitly sets the path_parameters on the request object to only the controller/action, so routing would fail to match without the nested resource as well.

The attached diff has a patch which I believe relieves the issue as I can then set additional path parameters in my spec and everything's happy.

The example within the diff fails though, since it seems there's no access to the request object within that spec? Is there a better way to do this..?

This is using edge rails/rspec, but I believe another person (srogers in #rspec) was seeing it on 2.1 and edge rspec

Comments and changes to this ticket

  • David Chelimsky

    David Chelimsky November 22nd, 2008 @ 02:17 AM

    • → State changed from “new” to “open”

    Hey Mike - I committed your patch plus some changes to get it to work like this:

    
    render "/path/to/file", :controller => "foo", :action => "bar"
    

    You can see the specs here: http://github.com/dchelimsky/rsp...

    Do you think that you need anything beyond controller and action? If so, I may prefer to handle this with a path_parameters pair:

    
    render "/path/to/file", :path_parameters => {:controller => "foo", :action => "bar"}
    

    Then you could add anything you want to the path_parameters. WDYT?

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Behaviour Driven Development for Ruby.

Shared Ticket Bins