Rails 会话不正确?

发布于 2024-11-01 09:08:31 字数 885 浏览 3 评论 0原文

我正在使用水豚进行集成测试,看起来传递给我的控制器以进行测试的“登录”部分的会话有问题。通过浏览器时登录工作正常,但在水豚中登录失败。

def integration_sign_in(user)
            visit signin_path

            puts "Pre email: " + user.email
            puts "Pre password: "  + user.password

            # When I use these, everything works correctly
            fill_in "session_email", :with => user.email
            fill_in "session_password", :with => user.password 

            # When I use these, the session is wrong
            # The params[:session][:email] on the server has the password field
            # The params[:session][:password] on the server is nil
            #fill_in :email,    :with => user.email
            #fill_in :password, :with => user.password

            click_button "Sign in"
        end

我可以不使用水豚测试符号吗?我的猜测是,在失败的情况下,第一个字段(电子邮件)被填写为两个字段,这就是为什么会话只有电子邮件值,而该值是密码。

I am using capybara for an integration test and it looks like something is wrong with the session that gets passed to my controller for my "sign in" part of a test. The sign in works fine when going through a browser, but is failing in capybara.

def integration_sign_in(user)
            visit signin_path

            puts "Pre email: " + user.email
            puts "Pre password: "  + user.password

            # When I use these, everything works correctly
            fill_in "session_email", :with => user.email
            fill_in "session_password", :with => user.password 

            # When I use these, the session is wrong
            # The params[:session][:email] on the server has the password field
            # The params[:session][:password] on the server is nil
            #fill_in :email,    :with => user.email
            #fill_in :password, :with => user.password

            click_button "Sign in"
        end

Can I not use symbols for the capybara tests? My guess is that the first field (email) is being filled in for both fields in the failing case, which is why the session only has a value for email and that value is password.

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

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

发布评论

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

评论(1

不知在何时 2024-11-08 09:08:31

看起来最新版本的水豚不能正确接受符号。仅当输入字段的完整字符串时它才有效。

It looks like the latest version of capybara doesn't accept symbols correctly. It only works when the full string of the field is entered.

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