# Problem finding method while testing a helper

**URL:** <https://www.ruby-forum.com/t/problem-finding-method-while-testing-a-helper/147957>\
**Category:** Rails\
**Created:** [September 7, 2008, 4:06pm UTC](https://www.ruby-forum.com/t/problem-finding-method-while-testing-a-helper/147957 "2008-09-07T16:06:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HSWade\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19adc/32.png) [@HSWade\_M](https://www.ruby-forum.com/u/HSWade_M)\
**Post date:** [September 7, 2008, 4:06pm UTC](https://www.ruby-forum.com/t/problem-finding-method-while-testing-a-helper/147957/1 "2008-09-07T16:06:39Z")

</div>

I’m trying to test the code in my helpers, using the great Viget Labs  
helper\_me\_test plugin. However, I’m running into an oddity (unrelated  
to the plugin - it was happening when I was trying to roll my own  
solution as well).

Here are snippets of the relevant code:

[http://pastie.org/private/5yop8zcceszxqfzedhata](http://pastie.org/private/5yop8zcceszxqfzedhata)

Basically, the ApplicationController defines a current\_user method,  
that returns a RackLdap object.

The helper I’m testing is calling that method.

This works fine when the app is running. But when I try to test, it  
seems like it’s trying to call ApplicationHelperTest::current\_user  
instead of ApplicationController::current\_user, and dying.

Any suggestions on how I can get past this? I’ve been staring at it  
for a couple of days and am stumped.

–Wade

---

<div class="post-metadata">

**Author:** ![HSWade\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19adc/32.png) [@HSWade\_M](https://www.ruby-forum.com/u/HSWade_M)\
**Post date:** [September 7, 2008, 6:35pm UTC](https://www.ruby-forum.com/t/problem-finding-method-while-testing-a-helper/147957/2 "2008-09-07T18:35:36Z")

</div>

On 7 Wrz, 16:05, “H. Wade M.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> that returns a RackLdap object.  
> –Wade  
> You could simply stub current\_user method to return you a valid user  
> object (see [mocha.rubyforge.org](http://mocha.rubyforge.org) or [flexmock.rubyforge.org](http://flexmock.rubyforge.org))

---

<div class="post-metadata">

**Author:** ![HSWade\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19adc/32.png) [@HSWade\_M](https://www.ruby-forum.com/u/HSWade_M)\
**Post date:** [September 7, 2008, 6:36pm UTC](https://www.ruby-forum.com/t/problem-finding-method-while-testing-a-helper/147957/3 "2008-09-07T18:36:46Z")

</div>

On Sep 7, 2008, at 11:34 AM, szimek wrote:

> > [http://pastie.org/private/5yop8zcceszxqfzedhata](http://pastie.org/private/5yop8zcceszxqfzedhata)  
> > Any suggestions on how I can get past this? I’ve been staring at it  
> > for a couple of days and am stumped.
> > 
> > –Wade
> 
> You could simply stub current\_user method to return you a valid user  
> object (see [mocha.rubyforge.org](http://mocha.rubyforge.org) or [flexmock.rubyforge.org](http://flexmock.rubyforge.org))

Would I stub ApplicationHelperTest::current\_user?

Thanks,  
Wade
