[rspec-users] helper spec not finding rails core helpers

linojon linojon at gmail.com
Tue Jul 31 00:20:03 EDT 2007


Hi,

My helper specs were going ok until I added a call to a rails  
DateHelper method in one of my helpers
http://api.rubyonrails.com/classes/ActionView/Helpers/ 
DateHelper.html#M000574

The helper runs fine from my view templates, just dies in the spec test.

I boiled my question down to a simple (not too useful) example. I'm  
not sure what I'm missing.

# application_helper.rb
module ApplicationHelper

   def app_foo
     t = Time.now
     distance_of_time_in_words( t, t + 50.minutes)
     return true
   end
end

# application_helper_spec.rb
require File.dirname(__FILE__) + '/../spec_helper'

describe ApplicationHelper do
   it "should find app_foo in application_helpers.rb" do
     app_foo.should be_true
   end
end

# error output
NoMethodError in 'ApplicationHelper should find app_foo in  
application_helpers.rb'
undefined method `distance_of_time_in_words' for [Dynamically  
generated class for RSpec example]:#<Class:0x32d11c8>


More information about the rspec-users mailing list