如何在不使用任何 gem 的情况下模拟任何方法?
假设我可以访问像request
这样的复杂对象
我该怎么做
request.location.country
返回模拟值。
我读到我可以用 gems 模拟 geocoder
结果,但我想知道一种通用的方法。
最佳答案
我是这样做的
foo = Geocoder.search('Paris, TX')
foo.first.county
我正在使用 BingAPI,为了弄清楚我可以在 foo.first
对象上访问哪些选项,我查看了 Geocoder 文档:
http://rdoc.info/github/alexreisner/geocoder/master/Geocoder/Result/Bing
关于ruby-on-rails - Geocoder 的手动模拟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16696770/