I'm using 'time_ago_in_words' function in a view, and I need to test the output in the FunctionalTest.
But the test can not see 'time_ago_in_words' helper function.
What should I do in order to use these helper methods from FunctionalTests?
Include the ActionView::Helpers::DateHelper
module in your test_helper.rb
or test.rb
files. And that's it, from the test console:
>> time_ago_in_words(3.minutes.from_now)
NoMethodError: undefined method `time_ago_in_words' for #<Object:0x3b0724>
from (irb):4
from /Users/blinq/.rvm/rubies/ruby-1.9.1-p376/bin/irb:15:in `<main>'
>> include ActionView::Helpers::DateHelper
=> Object
>> time_ago_in_words(3.minutes.from_now)
=> "3 minutes"
I added on rails_helper.rb
config.include ActionView::Helpers::DateHelper
and work's, thank's @jpemberthy!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With