[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
Tue Feb 10 16:23:02 EST 2009


Done:

http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/692-route-based-_url-or-_path-functions-dont-work-until-getpost-are-called


Randy


----- Original Message ----
> From: David Chelimsky <dchelimsky at gmail.com>
> To: rspec-users <rspec-users at rubyforge.org>
> Sent: Tuesday, February 10, 2009 12:15:48 PM
> Subject: Re: [rspec-users] resource urls only work *after* a get() in controller spec
> 
> On Mon, Feb 2, 2009 at 12:17 AM, Randy Harmon wrote:
> >
> > Okay, following up on this item.  Would you believe a workaround of (gasp) get 
> :index, prior to expecting route-based URLs to work?  (slaps forehead).  or 
> do_action(), provided by the host example group (the more concrete example 
> group, I mean - what's the right terminology there?).
> >
> > I tried reproducing the stuff I saw being done in 
> action_controller/test_process.rb up to the point where the resource url 
> function started working, but when I did that (setting up the controller name 
> and action, essentially), I wasn't getting it to work, but I ran out of time 
> budget for fooling with it.
> >
> > If anyone thinks of an approach that could be more robust, I'd sure be 
> interested.
> 
> This sounds like a bug - can somebody familiar w/ this problem please
> file a ticket at http://rspec.lighthouseapp.com?
> 
> Thanks,
> David
> 
> >
> > Until then,
> >
> >
> > Randy
> >
> >
> >
> > ----- Original Message ----
> >> From: "r_j_h_box-sf at yahoo.com" 
> >> To: rspec-users 
> >> Sent: Saturday, January 31, 2009 11:40:54 PM
> >> Subject: Re: [rspec-users] resource urls only work *after* a get() in 
> controller spec
> >>
> >> 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.
> >>
> >> Thanks,
> >>
> >> Randy
> >>
> >>
> >>
> >>
> >>
> >> ----- Original Message ----
> >> > From: Ben Mabey
> >> > To: rspec-users
> >> > 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
> >
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list