如何在 Cucumber 中测试 authlogic 的 current_user?

发布于 2024-07-19 06:29:33 字数 488 浏览 2 评论 0原文

我正在尝试在 Cucumber 中使用 authlogic 的测试助手,调用 activate_authlogic。

我们的 application_controller 有一个 current_user_session 方法。

当我们进入调试器中途时,controller 返回一个 Authlogic::TestCase::MockController

但是当我们调用controller.current_user_session时。

评估 nil.current_user_session 时发生错误。

这个模拟怎么突然变成了零?

这个模拟控制器知道我们的应用程序控制器的代码吗?

I am trying to use authlogic's test helpers in Cucumber, calling activate_authlogic.

Our application_controller has a current_user_session method.

When we drop into the debugger mid-story, controller returns a Authlogic::TestCase::MockController.

But when we call controller.current_user_session.

The error occurred while evaluating nil.current_user_session.

How does this mock suddenly become a nil?

And does this mock controller know about our application controllers' code?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执着的年纪 2024-07-26 06:29:33

我不知道 authlogic (如果这个答案有帮助的话),但是这个模拟对象首先来自哪里? 你不应该在黄瓜故事中使用任何模拟。 Cucumber 就像一个集成测试,测试完整的 Rails Stack。

我使用它来确保我的视图、控制器和模型规格没有相互偏离。

I don't know authlogic (and if this answer is helpful at all), but where does that mock object come from in the first place? You shouldn't be using any mocks in you cucumber stories. Cucumber is like an integration test, testing the complete Rails Stack.

I use it, to make sure, that my view, controller and model specs haven't diverged from each other.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文