使用黄瓜测试未经身份验证的用户设备
在此示例中: https://github.com/RailsApps/rails3-devise-rspec-cucumber
我收到错误,因为访问('/users/sign_out')(在水豚中......以确保用户已注销)失败。问题是没有 GET 到该路径的路由,因为 devise 将其更改为 DELETE(并且水豚不支持 PUT 和 DELETE,没有一些 js 解决方法)
您对执行“鉴于我是未经身份验证的用户”步骤有什么建议?你们通常怎么做?我希望有一个简单的方法可以解决这个问题,比如 1-2 行 ruby。
目前,我只是这样做:
Given "i am an unauthenticated user" do
@user == nil
end
但它看起来确实不像在测试任何东西。
IN this example: https://github.com/RailsApps/rails3-devise-rspec-cucumber
I get an error because doing visit('/users/sign_out') (in capybara..to ensure a user is logged out) fails. The problem is there's no route for a GET to that path, since devise changed it to DELETE(and capybara doesn't support PUT and DELETE without some js workarounds)
What are your suggestions in doing the "Given I am an unauthenticated user" step? how do you guys usually do it? I am hoping there's an easy way out of this like 1-2 lines of ruby.
at the moment, i just do :
Given "i am an unauthenticated user" do
@user == nil
end
but it sure doesn't look like it's testing anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的——这对很多人来说有点痛苦。
解决这个问题的最简单方法是将其放入 /config/initializers/devise.rb 文件中:
这将为您的测试环境使用旧的 get 方法,并删除所有其他环境。
Yeah - this has been a bit of a pain for lotsa folks.
The easiest way to get around it is to throw this in your /config/initializers/devise.rb file:
This will use the old get method for your test environment, and delete for all others.