oauth 提供商的 Rspec 测试
我正在编写一个 API,它也是一个 OAuth 提供程序。有没有推荐的方法来编写 rspec 测试?
启用 oauth 来保护所有端点后,如何编写将通过身份验证步骤的 rspec 测试?
I'm writing a API that's also an OAuth provider. Is there any recommended way to write your rspec tests?
After you enable oauth to protect all of your endpoints, how do you write rspec tests that will pass the authentication step?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在使用 oauth 和 oauth-plugin gems,这篇文章可能会帮助您:
http://peachshake.com/2010/11 /11/oauth-capybara-rspec-headers-and-a-lot-of-pain/
然而,oauth-plugin gem 会生成一些规范,其中包括一个帮助程序来帮助您模拟身份验证过程。
看看这个文件:
https://github.com/pelle/ oauth-plugin/blob/v0.4.0.pre4/lib/generators/rspec/templates/controller_spec_helper.rb
您可以使用以下方法来签署您的请求:
我建议您复制此文件作为您的帮助程序规格并根据您的需要进行相应修改。
If you are using the oauth and oauth-plugin gems, this post might help you:
http://peachshake.com/2010/11/11/oauth-capybara-rspec-headers-and-a-lot-of-pain/
Yet, the oauth-plugin gem generates some specs which include a helper to help you simulate the authentication process.
Take a look at this file:
https://github.com/pelle/oauth-plugin/blob/v0.4.0.pre4/lib/generators/rspec/templates/controller_spec_helper.rb
You can use the following methods to sign your requests:
I suggest you to copy this file as a helper for your specs and modify accordingly to your needs.