How do I mock an object in this case? no obvious way to replace object with mock
Posted
by
Tristan
on Stack Overflow
See other posts from Stack Overflow
or by Tristan
Published on 2011-02-01T23:14:02Z
Indexed on
2011/02/01
23:26 UTC
Read the original article
Hit count: 550
Hi there,
Suppose I have this very simple method in Store's model:
def geocode_address
loc = Store.geocode(address)
self.lat = loc.lat
self.lng = loc.lng
end
If I want to write some test scripts that aren't affected by the geocoding service, which may be down, have limitations or depend on my internet connection, how do I mock out the geocoding service? If I could pass a geocoding object into the method, it would be easy, but I don't see how I could do it in this case.
Thanks!
Tristan
© Stack Overflow or respective owner