黄瓜与水豚中的 allocate() 的替代方案?

发布于 2024-09-03 05:41:31 字数 401 浏览 3 评论 0 原文

我正在尝试使用 capybara 和 cucumber 来获得更好的 javascript 测试覆盖率。我有很多步骤来检查或使用 Rails 集成测试助手中的内容,例如:

assigns(:current_user).should_not be_nil

无论我如何调用 assigns,即使我说类似 p allocates它的错误是:

undefined method `template' for nil:NilClass (NoMethodError)

所以,看来我不能再这样做了。除了反思控制器中发生的情况之外,是否有其他方法,或者至少可以通过某种方式运行这些步骤,以便我可以返回集成测试内容?

I'm trying out capybara with cucumber to get some better javascript test coverage. I have a lot of steps that check or use things from the Rails integration test helpers, for instance:

assigns(:current_user).should_not be_nil

No matter how I call assigns, even if I say something like p assigns it errors with:

undefined method `template' for nil:NilClass (NoMethodError)

So, it seems that I can't do that anymore. Is there an alternative to introspecting what's going on in the controller, or maybe some way of at least running those steps in such a way that I have the integration test stuff back?

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

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

发布评论

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

评论(1

暖伴 2024-09-10 05:41:31

不幸的是没有。 Capybara 测试机架应用程序,除了通过标准机架接口(即发出 HTTP 请求)之外,无法与机架应用程序内部的内容进行通信。机架应用程序内发生的任何事情对于 Capybara 来说都是不可见的。

Unfortunately there isn't. Capybara tests rack apps, and has no way of communicating with what's inside that rack app other than through the standard rack interface (i.e. issueing HTTP requests). Anything that happens inside the rack app is invisible to Capybara.

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