使用 Minitest 和身份验证进行功能测试
我正在尝试进行功能测试,但我不知道如何处理 cookie。 我正在使用 Ruby 和 Minitest 进行控制器的功能测试。 但要在控制器中运行测试,首先我需要进行身份验证。 身份验证使用 cookie 来查看用户是否已登录。 问题是功能测试看不到 cookie 中的内容,因此我无法进行身份验证然后运行测试。有人给我提示来解决这个问题吗?
谢谢 赫伯
I'm trying to do functional test but I don't know how to deal with cookies.
I'm using Ruby and Minitest to do functional test of controllers.
But to run tests in controllers, first I need to authenticate.
The authentication uses cookies to see if the user is logged or not.
The problem is functional tests do not see what is in cookies, than I can't authenticate and then run tests. Does someone give me a tip to resolve this?
thanks
Heber
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己也在看同样的问题。由于对此有些陌生,我实际上不确定这是否有效,但我打算尝试使用
before do
挂钩来运行身份验证。有这样的效果:
I'm looking at the same issue, myself. Being somewhat new at this, I'm not actually sure this will work, but I intend to try using the
before do
hook to run an authentication.Something to this effect: