黄瓜/水豚返回“未找到”重定向后的页面

发布于 2024-10-03 14:33:37 字数 165 浏览 1 评论 0原文

首先,抱歉英语不好。

我有一个提交登录表单的测试。 重定向后,当我测试消息“成功记录...”时 那么我的 page.body 是

'

Not Found

'

但这在浏览器手动测试中完美运行。

我应该做错什么?

first, sorry for the bad english.

I have a test that submit a login form.
after redirect, when I test for a message 'successfully logged...'
then my page.body is

'<h1>Not Found</h1>'

but this works perfectly on browser manual test.

what should I'm doing wrong?

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

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

发布评论

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

评论(2

微暖i 2024-10-10 14:33:37

听起来您的其中一个步骤可能是以您意想不到的方式进行重定向。

  1. 检查控制器和 application_controller 上的 before 过滤器,以确定登录/I18n 过滤器是否正在重定向您的页面。

  2. 如果您安装了 launchy gem,您还可以将以下内容添加到您的步骤中:

    并显示页面
    

    这将启动浏览器,显示水豚实际查看的内容,这对于检查步骤的完整性很有用。

祝你好运!

Sounds likely that one of your steps is redirecting in a way that you do not expect.

  1. Check your before filters on the controller and application_controller to determine whether a login/I18n filter is redirecting your page.

  2. If you have the launchy gem installed, you can also add the following to your steps:

    And show me the page
    

    Which will fire-up a browser with what capybara is actually looking at, which is useful for sanity checking your steps.

Good luck!

夜清冷一曲。 2024-10-10 14:33:37

测试在其自己的干净数据库副本下运行。确保您首先使用rake db:test:prepare进行设置,并且您正在创建测试所需的所有数据作为该功能的一部分。 (即假设有一个名为“Joe”的用户...

Tests run under their own clean copy of the database. Make sure you've set it up first using rake db:test:prepare, and that you're creating all the data you need for your tests as part of the feature. (I.e. Given there is a user named "Joe"...)

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