跨重定向的 Cucumber 和持久会话

发布于 2024-11-16 11:10:25 字数 1292 浏览 0 评论 0原文

rails - 2.3.8
cucumber - 0.8.5
cucumber-rails - 0.3.2
capybara - 0.4.0

正在尝试测试一个特定的登录/注册场景,其中用户在登陆所需页面之前被重定向。在重定向时,cucumber 会刷新会话,即用户不再登录。

有关如何防止这种情况的任何想法?

编辑

我尝试测试的功能如下:

Feature: Check Register and SignUp  
    In order to use products
    As a User
    I want to register and login

    @javascript
    Scenario: Register on Landing Page
            When I go to Landing Page
            And I fill in "user_email" with "[email protected]"
            And I fill in "user_email_confirmation" with "[email protected]"
            And I fill in "user_password" with "testpass"
            And I select "State" from "state"
            And I press "Register Free"
            And I wait until Ajax requests are complete
            Then I should be on Home

当我向该功能添加并向我显示页面时,我再次看到登陆页面

编辑2

我正在使用restful_authentication 进行身份验证。 实际工作是,当表单提交时,用户被带到一个页面,然后重定向到主页。这在手动测试时有效,但在使用黄瓜时无效。

编辑 3 代码格式化

Im using

rails - 2.3.8
cucumber - 0.8.5
cucumber-rails - 0.3.2
capybara - 0.4.0

I am trying to test a particular login/registration scenario where the user is redirected before landing on the required page. On redirect, cucumber flushes the session ie the user is no longer logged in.

Any ideas on how to prevent this?

EDIT

The feature im trying to test is as follows:

Feature: Check Register and SignUp  
    In order to use products
    As a User
    I want to register and login

    @javascript
    Scenario: Register on Landing Page
            When I go to Landing Page
            And I fill in "user_email" with "[email protected]"
            And I fill in "user_email_confirmation" with "[email protected]"
            And I fill in "user_password" with "testpass"
            And I select "State" from "state"
            And I press "Register Free"
            And I wait until Ajax requests are complete
            Then I should be on Home

When i add And show me the page to the feature, i see the Landing Page again.

Edit 2

I'm using restful_authentication for authentication.
The actual working is, when the form submits, the user is taken to a page and then redirected to the home page. This works when testing manually, but not when using cucumber.

Edit 3
Code formatting

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

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

发布评论

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

评论(1

眼泪也成诗 2024-11-23 11:10:25

也许是一个愚蠢的细节,但您是否仔细检查过您设置的路径的 url 是否与 cuke 配置中的站点主机匹配?在测试一些跨站点 JSON-P 内容时,这让我们困扰了一段时间......

perhaps a silly detail, though have you double checked that the url of the paths you've set match the site host in your cuke config? This bit us for a while while testing some cross-site JSON-P stuff...

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