Closed sshaw closed 13 years ago
Hi,
for test purposes, I do use class_eval, see here: https://github.com/apneadiving/Google-Maps-for-Rails/blob/master/test/dummy/spec/models/user_spec.rb
I suggest the following:
e.after_build do |ev|
ev.class.class_eval do
def gmaps4rails_options
#redefine whole hash here
end
end
end
Yes, I think that's a better route.
Slightly modified :
ev.instance_eval do
@__gmaps4rails_options = gmaps4rails_options.merge(:validation => false)
def gmaps4rails_options
@__gmaps4rails_options
end
end
Thanks!
Hello,
Since
model.gmaps4rails_options
returns a new hash each time it's called one cannot modifying an including instance's options. This makes sense though, as most of the options shouldn't be modified, but how can one easily run their unit tests without using real addresses or installing a mock lib.Instead I've had to do the more invasive:
acts_as_gmappable :validation => !Rails.env.test?
Maybe there's a better way?