I am using gmaps4rails and trying to develop some tests.
I have a factory
factory :country do
sequence(:name) { |n| "Country#{n}" }
end
which is obviously not recognized by Google.
Validation failed: Gmaps4rails address Address invalid
An API call also takes time to execute in my tests.
How can I drown out an API call?
I tried adding
before(:each)
Country.stub(:geocode)
end
in the spec file, but it has no effect.
My model looks like
class Country < ActiveRecord::Base
acts_as_gmappable :lat => 'latitude', :lng => 'longitude'
def gmaps4rails_address
"#{self.name}"
end
geocoded_by :gmaps4rails_address
after_validation :geocode
end
Thanks for any ideas.
source
share