Cucumber 功能/Rspec 与第三方 oAuth API
我正在将 Cucumber 和 RSpec 用于我的新 ruby on Rails 应用程序,并将使用一些第三方 oAuth API 来发送/检索数据。我对 Cucumber 和 RSpec 都很陌生,以前从未需要实现这样的第三方功能。从规范和功能编写的角度来看,处理此问题的最佳方法是什么?我知道我不应该直接查询服务,因为我无法指定它们的启动或关闭等,所以我确信我需要存根/模拟一些对象/函数。任何有关此事的帮助将不胜感激。
I am using cucumber and RSpec for my new ruby on rails application and will be using some third party oAuth APIs to send/retrieve data. I am fairly new to both cucumber and RSpec and have never had to implement third party functionality like this before. What is the best way to handle this from a spec and feature writing perspective? I know I shouldn't be querying the services directly, because I can't spec for them being up or down, etc, so I'm sure I will need to stub/mock some objects/functions. Any help in this matter would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用一个名为 webmock 的 gem,并根据我知道的良好结果来删除请求。
您还可以使用 EphemeralResponse 自动记录请求,但我还没有使用过。
I use a gem called webmock and stub out the requests with results that I know are good.
You can also automatically record requests with EphemeralResponse, but I haven't used that yet.