Thanks, that did the trick. And for including ApplicationHelper, I would say it should include it - because that would parallel Rails' standard behavior.
On Mon, Sep 15, 2008 at 3:34 PM, David Chelimsky <[EMAIL PROTECTED]>wrote: > On Mon, Sep 15, 2008 at 4:06 PM, Christopher Bailey > <[EMAIL PROTECTED]> wrote: > > If I don't include them, then the helpers in LocationsHelper can't > find/use > > the helpers in ApplicationHelper. Maybe this will help illustrate: > > test code: > > describe LocationsHelper do > > describe "location tree" do > > it "should not show siblings for state, country, or root level > > locations" do > > helper.location_tree(@oregon).should_not include_text(@hawaii.name > ) > > end > > end > > end > > The location_tree method is defined in the module/helper LocationsHelper. > > But, it calls ApplicationHelper.markaby. When I run the above test, it > > can't find the markaby method/helper. It will only find markaby if I > remove > > the leading "helper." from in front of the call, and also include > > ApplicationHelper (including this, when using helper. doesn't remedy it). > > OK - in the short run, I'd do this as a workaround instead: > > helper.extend ApplicationHelper > > You can do that in a before block or in the examples directly. > > This is a better option because you'll soon not have direct access to > the helper methods in the examples except through the helper object. > > Next question is whether rspec-rails should just include the > ApplicationHelper module into the helper object. My instinct is yes. > WDYT? > > Cheers, > David > > > > > On Mon, Sep 15, 2008 at 11:15 AM, David Chelimsky <[EMAIL PROTECTED]> > > wrote: > >> > >> On Mon, Sep 15, 2008 at 12:26 PM, Christopher Bailey > >> <[EMAIL PROTECTED]> wrote: > >> > I'm trying to test some of my helpers. I have one helper (in module > >> > LocationsHelper) that calls a helper/method in ApplicationHelper. If > I > >> > include ApplicationHelper and LocationHelper in my spec, and then I > call > >> > the > >> > helper using the "helper." scope: > >> > helper.location_tree('Portland') > >> > then it complains that it can't find the other helper it uses from > >> > ApplicationHelper. If instead, I call it directly: > >> > location_tree('Portland') > >> > Then, it can't find the Rails' generated URL helpers (e.g. > >> > "location_path" > >> > or "location_url"). How do I make it so that all the dependencies or > >> > Rails' > >> > included stuff is found? > >> > >> You don't need to include the helpers if you are using the helper > >> object. You should be able to do just this: > >> > >> describe LocationsHelper do > >> it "should ..." do > >> helper.location_tree('Portland').should ... > >> end > >> end > >> > >> Have you tried that? Does it fail? > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users@rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > -- > > Christopher Bailey > > Cobalt Edge LLC > > http://cobaltedge.com > > > > _______________________________________________ > > 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 > -- Christopher Bailey Cobalt Edge LLC http://cobaltedge.com
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users