将 Cucumber 与 Authlogic 结合使用

发布于 2024-09-11 01:15:37 字数 579 浏览 2 评论 0原文

我最近将 Cucumber 升级到版本 0.8.5,但 Authlogic 出现一些意外错误。作为许多用户界面测试的先驱,我有一个默认的“假设我已登录”方法,该方法通过标准登录界面登录用户并断言他们已重定向到主页。在升级 Cucumber 之前,我对这种方法没有任何问题,但是当我现在运行测试时,我在 Authlogic 提供的 current_user 帮助程序上收到 NoMethodError 错误。用户似乎登录正常(因为登录后没有断言他们位于主页上),但是一旦在主页上调用“current_user”方法,它就会返回一个错误符号。 current_user 帮助器很简单 足够的。它所做的只是验证当前会话是否与用户匹配,如果不匹配则返回 false。

def current_user
@current_user ||= (session[:user] && User.find(session[:user])) || :false
end

这让我认为 Cucumber 0.8.5 正在让我登录,但没有存储我的会话数据。我错过了什么吗?我听说最近版本的 Cucumber 在存储会话数据方面存在问题,但我无法解决这个问题。还有其他人有类似的问题吗?

I recently upgraded cucumber to version 0.8.5, but I'm getting some unexpected errors with Authlogic. As a precursor to many of my user interface tests I have a default 'Given I am logged in' method that logs a user in through the standard login interface and asserts that they were redirected to the home page. Prior to upgrading cucumber I had no issue with this method, but when I run my tests now I get a NoMethodError on my the current_user helper provided by Authlogic. The user seems to log in fine (as there is no issue asserting that they are on the homepage after login), but as soon as 'current_user' method is called on the homepage it returns a false symbol. The current_user helper is simple
enough. All it does is validate that the current session matches up with a user, and if it doesn't then it returns false.

def current_user
@current_user ||= (session[:user] && User.find(session[:user])) || :false
end

This makes me think that Cucumber 0.8.5 is logging me in, but not storing my session data. Am I missing something? I've heard that recent versions of Cucumber have had issues with storing session data, but I can't figure this one out. Anyone else had a similar problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文