Ruby on rails rspec+;capybara rails 4-rake集成测试失败

Ruby on rails rspec+;capybara rails 4-rake集成测试失败,ruby-on-rails,ruby,rspec,devise,capybara,Ruby On Rails,Ruby,Rspec,Devise,Capybara,我正在尝试测试设计登录、注销和所有其他场景,但是我无法让一个场景成为过去,让我们假设登录失败 在我的特写中我有 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

我正在尝试测试设计登录、注销和所有其他场景,但是我无法让一个场景成为过去,让我们假设登录失败

在我的特写中我有

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 helper设置为

 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

有什么想法吗?

您将助手方法命名为“登录”,但在您的场景中调用的是“登录”。您应该使用一种或另一种方法,而不是同时使用两种方法

更新:好的,重新检查了,您应该使用自己的帮助程序模拟实际用户登录,或者使用Warden提供的
login\u作为
,在这种情况下,请确保您的测试/rspec设置中包含此项:

include Warden::Test::Helpers
Warden.test_mode!

另一方面,你应该在你的工厂/设备中确认你的用户,而不是在你的助手方法(可能没有定义)中确认你的用户。

为此,我最终删除了额外的助手,并以,我已经确保我包含了warden Test::Helpers,但是我现在遇到了一个不同的问题失败/错误:expect(第页)。要使内容I18n.t“design.Failure.not_found_in_database”,身份验证密钥:“email”应该在中找到文本“Invalid email or password.”“TypeError at/overviews=========================>没有将符号隐式转换为整数您的overviews控制器是什么样的?“符号到整数的隐式转换”是从哪一行触发的?这是一个不同于登录的问题。