0

我想在使用 javascript 的测试期间以用户身份登录,所以我想我应该有一个帮助方法,通过前端登录用户。然而有了帮手

    def log_user_in_via_frontend(user)
        visit root_path
        fill_in 'user_session_login', :with => user.login
        fill_in 'user_session_password', :with => user.password
        click_on('Login')
    end

只要我不放在:js => true最后,我就可以登录并被重定向到正确的页面。我通过调用这个助手

    user = FactoryGirl.create(:user)
    log_user_in_via_frontend(user)

之后访问 root_path 会产生No route matches {:controller=>\"users\", :action=>\"show\", :id=>#<User id: nil, login: nil...

在我的硒测试中登录用户的最佳方式是什么?

4

1 回答 1

0

实际上,到目前为止,这对我有用。我不确定到底是什么,但我认为关键是停用过渡固定装置,并让数据库清理器进行清理。

于 2012-12-13T10:47:12.353 回答