Forum: Ruby on Rails Helper Methods - Help!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ccfe7d097475a32dc3ff78d6fc42c852?d=identicon&s=25 List Recv (lstrecv)
on 2005-12-18 06:53
How can I call a helper method standalone, that is, not within a
controller or anything?  For instance, let's say I have a class - not a
subclass of ActiveAnything - that wants to do url_for , or the like?

The reason I am asking is that I want to create *UNIT* tests for my
helper methods, but can't get them to work.  I can't figure out how to
invoke them outside of templates or controllers.

Am I the only one that has thought to unit test my helpers?  How does
everyone else do it?
D8cb8c8cd40ddf0cd05241443a591868?d=identicon&s=25 Duane Johnson (Guest)
on 2005-12-18 23:20
(Received via mailing list)
On Dec 17, 2005, at 10:53 PM, List Recv wrote:

> everyone else do it?
>

There was some discussion of this a little while ago.

http://article.gmane.org/gmane.comp.lang.ruby.rail...
+test+helpers

Duane Johnson
(canadaduane)
741a3b49ae2937c3d62e45d1699b674a?d=identicon&s=25 Steven R. Baker (Guest)
on 2005-12-19 05:30
(Received via mailing list)
> The reason I am asking is that I want to create *UNIT* tests for my
> helper methods, but can't get them to work.  I can't figure out how to
> invoke them outside of templates or controllers.
>
> Am I the only one that has thought to unit test my helpers?  How does
> everyone else do it?

You don't need to unit test your helpers.  Helpers are like private
methods, they're arrived at by extraction.

If you write a view, and your tests pass.  Then when you extract the
functionality to a helper, if your tests still pass, then you've
extracted properly.

-Steven
This topic is locked and can not be replied to.