On 2 Feb 2009, at 06:18, r_j_h_box...@yahoo.com 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

That's what I was going to suggest. We have all our routing tests in a separate file (away from the controllers) and this what we do there.

forehead).  or do_action(), provided by the host example group (the
more concrete example group, I mean - what's the right terminology
there?).

This is another approach that can work too. We call it #do_request.

You can override helper methods like this as you go into describe blocks so you can have a very basic on the outside level and specialise it as you get into more detail.

\
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 a better way, I'm all ears.

Until then,

Randy



----- Original Message ----
From: "r_j_h_box...@yahoo.com" <r_j_h_box...@yahoo.com>
To: rspec-users <rspec-users@rubyforge.org>
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...@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@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to