为 rspec 中的所有控制器/请求规范强制使用 HTTPS/SSL [英] Force HTTPS/SSL for all controller/request specs in rspec

查看:40
本文介绍了为 rspec 中的所有控制器/请求规范强制使用 HTTPS/SSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 RSpec 3.5.0,并希望为我的所有规范启用 HTTPS/SSL 请求.

I'm using RSpec 3.5.0, and would like to enable HTTPS/SSL requests for all my specs.

自从我将 force_ssl 添加到我的 ApplicationController 后,我的所有规范都失败了,因为它们正在重定向到网站的安全版本而不是渲染等.>

Since I added force_ssl to my ApplicationController, all my specs are failing, since they are redirecting to the secure version of the site instead of rendering, etc.

推荐答案

此处的建议在 rails 5 下不起作用.如果这是您遇到问题的一部分,请将 https! 添加到您的规范中应该工作.

The suggestions here don't work under rails 5. If that's part of where you're stuck adding https! to your spec should work.

这篇关于为 rspec 中的所有控制器/请求规范强制使用 HTTPS/SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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