[rspec-users] resource urls only work *after* a get() in controller spec

r_j_h_box-sf at yahoo.com r_j_h_box-sf at yahoo.com
Sun Feb 1 02:40:54 EST 2009

thanks, Ben - that didn't do the trick, though.

I traced it down as far as this:

the controller hasn't initialized its current url - that's the immediate cause of the method-on-nil complaint.  It hasn't, because the controller isn't technically handling a request yet (i.e., process()).  I tried monkey-patching the controller to allow me to call its initialize_current_url to get around this, but I didn't (yet) find how to fake up its request and params sufficiently to have that work.  

Understandably, the controller can't know what the current url is, unless rpsec-rails were to have a way to discover it from the example group.  I'm not sure that I'm proposing a change to a declarative style for controller actions - for my purpose, I'd be satisfied to fake it to think 'index' is the current url (in advance of processing the real request as specified by get() and friends).

Hopefully this rings enough bells to make a workaround self-evident to somebody.  Anybody?  Else I'll see what I can dig up from the rspec/rspec-rails source that can be enough of a resource.



----- Original Message ----
> From: Ben Mabey <ben at benmabey.com>
> To: rspec-users <rspec-users at rubyforge.org>
> Sent: Saturday, January 31, 2009 5:41:56 PM
> Subject: Re: [rspec-users] resource urls only work *after* a get() in controller spec
> r_j_h_box-sf at yahoo.com wrote:
> > I'm encountering an interesting symptom during example execution.  I'm
> > making a shared example group that dries up belongs-to-me before_filter
> > testing, and it makes a callback to the example group that says
> > it_should_behave_like that.  The callback tells the shared example
> > where to expect a redirect for failure.
> > 
> > It seems that prior to
> > executing a get() (etc), the resource-based url functions aren't
> > accessible.  Following the get(), topics_url works fine.  But before
> > then, it gives an error like this:
> > 
> > http://pastie.org/376096
> > 
> > Is
> > this a known issue?  Is there a workaround I can use?  
> For a workaround try doing a "include ActionController::UrlWriter" in your 
> shared example group.
> -Ben
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list