Cucumber:访问步骤定义中的当前控制器实例

发布于 2024-07-25 07:48:11 字数 326 浏览 2 评论 0原文

我想访问我的黄瓜步骤定义中的控制器实例。 这样做的目的是让我可以操作 http cookie 和会话值。 我很确定有一种方法可以通过 World 来做到这一点,但我不确定如何做。

关于 Ryan 的评论,我正在为需要登录用户的页面编写一个功能(通过 Authlogic)。 我知道黄瓜的方法是进入登录页面并登录用户,然后再继续。 但是,我正在使用 OpenID,并且在编排该过程时遇到了麻烦。 无论如何,我想在编写我的专题时避免这一步。 该功能并不是用户可以转到登录页面并登录然后执行某些操作; 这是用户登录后可以执行的操作。

谢谢,

迈克

I'd like to access the controller instance in my cucumber step definitions. The purpose of this is so I can manipulate http cookie and session values. I'm pretty sure there's a way to do this via World, but I'm not sure how.

In regards to Ryan's comment, I'm writing a feature for a page which requires a logged in user (via Authlogic). I know the cucumber way is to go to the login page and login a user before continuing. However, I'm using OpenID and have been having trouble orchestrating the process. Regardless, I'd like to avoid that step in writing my feature. The feature isn't that a user can go to the login page and login then do something; it's what the user can do once they're logged in.

Thanks,

Mike

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

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

发布评论

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

评论(2

我们的影子 2024-08-01 07:48:12

只需在您的步骤中使用@controller

Just use @controller in your steps

笔芯 2024-08-01 07:48:11

通常,不鼓励直接从 Cucumber 功能内访问控制器。 这个想法是功能测试用户看到的内容。 您的用户现在无法真正访问您的控制器,可以吗?

作为替代,您可能应该编写处理控制器级别检查的规范。

Generally it is discouraged to access controllers directly from within Cucumber features. The idea is that features test what your user sees. Your user's can't really access your controllers now, can they?

In lieu of this you should probably write specs that handle the controller-level checking.

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