I've reviewed a few of the Gmaps4rails stubbing questions and think I'm very close, but not quite there. Forgive me: Very new to stubbing and mocking in rails.
All of this code works in the real world, just trying to get it to skip geocoding during testing. Right now tests sometimes work and sometimes fail with the Gmaps4rails address Address invalid error
So, I have a very simple party.rb model that acts_as_gmappable:
def gmaps4rails_address
"#{self.city}, #{self.country}"
end
I've pasted geocoding.rb from github and placed it in /spec/support unmodified
However, I can't seem to tell my parties_controller_spec to use the stub instead of the real one. I'm sure I'm missing something simple... I've tried:
include Geocoding
and even
Gmaps4rails.set_gmaps4rails_options!({:msg => "quack"})
and I don't see "quack" as the error message, I see Validation failed: Gmaps4rails address Address invalid
Also tried:
Gmaps4rails.set_gmaps4rails_options!({:validation => false, :check_process => false, :process_geocoding => false})
But to no effect.
My factories.rb has a straightforward :party define:
Factory.define :party do |party|
party.name "Thai New Year"
party.city "Phuket"
party.country "Thailand"
...
end
So, I'm pretty sure I haven't properly told rspec to use the stubbed Gmaps4rails. So, where exactly do I put the code that tells Gmaps4rails to use your stub_geocoding method instead of actually trying to perform geocoding?
Any help would be appreciated... Sorry if this is a mundane question.
Dave
Do this if you don't want any geocoding:
Factory.define :party do |party|
party.name "Thai New Year"
party.city "Phuket"
party.country "Thailand"
party.gmaps true #<= this is what tells the gem not to fire geocoding
party.latitude whatever_if_relevant
party.longitude whatever_if_relevant
...
end