如何选择模拟地理编码器? [英] How can I optionally mock geocoder?

查看:254
本文介绍了如何选择模拟地理编码器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在某些测试中嘲笑 geocoder gem的结果。

I'd like to be able to mock the results of the geocoder gem in some of my tests.

我使用RSpec和Cucumber。在黄瓜我想默认嘲笑Geocoder的结果,但能够通过添加一个标签再次打开它。这将是完美的!类似的东西RSpec也将是好的。这将大大加快我的测试。

I use RSpec and Cucumber. In cucumber I'd like to default to mocking the Geocoder results, but be able to turn it back on again by adding a tag. That would be perfect! Something similar for RSpec would be good too. It would speed up my tests enormously.

我知道有一些宝石可以做类似的事情,例如。 sunspot_test

I know there are some gems out there for doing similar things, e.g. sunspot_test for sunspot. Is there anything similar for geocoder?

推荐答案

Im使用 vcr gem for远程服务,检查出来!它可以在您的情况非常有用。 github.com/myronmarston/vcr

Im using vcr gem for remote services, check it out! It can be very useful in your situation. github.com/myronmarston/vcr

这篇关于如何选择模拟地理编码器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆