[英]rspec + capybara rails 4 - rake integration testing fails
我正在尝试测试设计登录,注销和所有其他方案,但是我无法过去一个方案,请让登录失败
在我的特征中
scenario 'user cannot sign in if not registered' do
login_as('user2@example.com', 'meow')
visit overviews_path
save_and_open_page
expect(page).to have_content I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'email'
end
我也有sign_in帮助程序设置为;
def sign_in(email, password)
user.confirm!
visit new_user_session_path
fill_in 'Email', with: email
fill_in 'password', with: password
click_button 'Log in'
end
但是,这会导致错误;
expected to find text "Invalid email or password." in "TypeError at /overviews ======================= > no implicit conversion of Symbol into Integer spec/features/users/sign_in_spec.rb, line 14
有任何想法吗?
您已将助手方法命名为sign_in
但在您的方案中正在调用login_as
。 您应该使用一种方法或另一种方法,不能同时使用两种方法。
更新:好的,重新检查文档 ,并且您应该使用自己的帮助程序来模拟实际的用户登录,或者使用login_as
提供的login_as
,在这种情况下,请确保login_as
其包含在测试/ rspec中设定:
include Warden::Test::Helpers
Warden.test_mode!
附带说明一下,您应该在工厂/夹具中确认用户,而不是在helper方法(可能未定义)中确认用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.