[rspec-users] 'lazy' url generation in view specs

David Chelimsky dchelimsky at gmail.com
Sun Nov 18 10:15:13 EST 2007

On Nov 15, 2007 3:59 AM, Ingo Weiss <ingo at ingoweiss.com> wrote:
> Hi,
> I would like to use the 'lazy' style of url generation in my views,
> omitting parameters from my calls to url_for (and named route
> methods) that are then filled in from the current request parameters.
> Example:
> url_for(:action => 'index') will fill in (:controller => 'posts') if
> params[:controller] is 'posts'
> However, this breaks my view specs because when they render the view
> there is no request from which to fill in the missing parameters. How
> can I stub/mock the request so that the 'lazy' url-generation works
> in view spec? I tried a number of things, none of them working,
> including this:
> @controller.stub!(:params).and_return({:controller =>
> 'posts', :action => 'show'})

I don't think there is any way to do this yet. There is an open ticket
in the tracker:


> Ingo
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list