Reputation: 10009
I get this error when I run my test
spec/helpers/bikes_helper_spec.rb:3:in `<top (required)>':
uninitialized constant BikesHelper (NameError)
bikes_helper
require "spec_helper"
describe BikesHelper do
describe "#km_until_next_service" do
it 'returns a human readable number' do
expect(km_until_next_service(1000)).to eq '1000 kilometers'
end
end
end
app/helpers/bikes_helper.rb
module BikesHelper
include ActionView::Helpers::NumberHelper
def km_until_next_service(km_untill_next)
if km_untill_next == 0
return "NOW"
elsif (km_untill_next < 0)
return "Overdue by #{number_to_human(km_untill_next, unit: :distance)}"
elsif (km_untill_next > 0)
return "In #{number_to_human(km_untill_next, unit: :distance)}"
end
end
end
Any idea why it does not recognise BikesHelper?
Upvotes: 1
Views: 536