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?
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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.