# Testing helper/view methods from script/console

**URL:** <https://www.ruby-forum.com/t/testing-helper-view-methods-from-script-console/127993>\
**Category:** Rails\
**Created:** [February 4, 2008, 12:56am UTC](https://www.ruby-forum.com/t/testing-helper-view-methods-from-script-console/127993 "2008-02-04T00:56:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![galeal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@galeal](https://www.ruby-forum.com/u/galeal)\
**Post date:** [February 4, 2008, 12:56am UTC](https://www.ruby-forum.com/t/testing-helper-view-methods-from-script-console/127993/1 "2008-02-04T00:56:57Z")

</div>

Hi,

Is it possible to test helper/view methods from script/console. I want  
to test the output of methods like distance\_of\_time\_in\_words. But it  
won’t let me from the console. What am I missing?

TIA  
Luke

---

<div class="post-metadata">

**Author:** ![galeal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@galeal](https://www.ruby-forum.com/u/galeal)\
**Post date:** [February 4, 2008, 1:15am UTC](https://www.ruby-forum.com/t/testing-helper-view-methods-from-script-console/127993/2 "2008-02-04T01:15:54Z")

</div>

On Feb 3, 2008, at 6:56 PM, Luke G. wrote:

> Hi,
> 
> Is it possible to test helper/view methods from script/console. I want  
> to test the output of methods like distance\_of\_time\_in\_words. But it  
> won’t let me from the console. What am I missing?
> 
> TIA  
> Luke

User the helper object:

> > helper.distance\_of\_time\_in\_words 92.minutes  
> > =\> “about 2 hours”

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![galeal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@galeal](https://www.ruby-forum.com/u/galeal)\
**Post date:** [February 4, 2008, 1:24am UTC](https://www.ruby-forum.com/t/testing-helper-view-methods-from-script-console/127993/3 "2008-02-04T01:24:06Z")

</div>

On 3 Feb 2008, at 23:56, Luke G. wrote:

> Hi,
> 
> Is it possible to test helper/view methods from script/console. I want  
> to test the output of methods like distance\_of\_time\_in\_words. But it  
> won’t let me from the console. What am I missing?

you need to include the appropriate module eg:

Fs-ElephantBook:fred fred$ ruby script/console  
Loading development environment (Rails 2.0.2)

> > require ‘action\_view/helpers/date\_helper’  
> > =\> []
> 
> > include ActionView::Helpers::DateHelper  
> > =\> Object
> 
> > distance\_of\_time\_in\_words\_to\_now Time.mktime(2008,2,3,4)  
> > =\> “about 20 hours”
> 
> >

>

---

<div class="post-metadata">

**Author:** ![galeal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@galeal](https://www.ruby-forum.com/u/galeal)\
**Post date:** [February 4, 2008, 1:25am UTC](https://www.ruby-forum.com/t/testing-helper-view-methods-from-script-console/127993/4 "2008-02-04T01:25:52Z")

</div>

On 4 Feb 2008, at 00:14, Rob B. wrote:

> > won’t let me from the console. What am I missing?
> > 
> > TIA  
> > Luke
> 
> User the helper object:
> 
> > > helper.distance\_of\_time\_in\_words 92.minutes  
> > > =\> “about 2 hours”

Neato! I’ve somehow managed to miss that one!

Fred

---

<div class="post-metadata">

**Author:** ![galeal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@galeal](https://www.ruby-forum.com/u/galeal)\
**Post date:** [February 4, 2008, 1:37am UTC](https://www.ruby-forum.com/t/testing-helper-view-methods-from-script-console/127993/5 "2008-02-04T01:37:56Z")

</div>

Awesome. Exactly what I was looking for.  
Thanks!
