RSPEC:在控制器中用 cookie 替换会话
最初我的控制器使用会话来存储变量
session["quiz_intro"] = 'true'
现在我已经用像这样的cookie替换了会话
cookies["quiz_intro"] = 'true'
控制器继续按预期工作但我编写的规范失败了。 我使用会话变量时的规格是这样的
request.session["quiz_intro"] = 'true'
现在规格看起来像这样
request.cookies["quiz_intro"] = 'true'
我无法弄清楚为什么我的规格失败了。使用 cookie 时,我还应该在规范中执行其他操作吗? 我正在使用 Rails3 和 rspec-rails 2.6.1
Initially my controller was using session to store a variable
session["quiz_intro"] = 'true'
Now I have replaced session with cookies like this
cookies["quiz_intro"] = 'true'
The controller keeps working as it is supposed to but the specs I have written fail.
My specs when I was using session variable were like this
request.session["quiz_intro"] = 'true'
Now the specs look like this
request.cookies["quiz_intro"] = 'true'
I cannot figure out why my specs are failing. Is thr anything else that I should do in specs when using cookies?
I am using rails3 and rspec-rails 2.6.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论