在rspec特性测试期间,Devise注销重定向的当前用户

时间:2016-05-09 15:08:31

标签: ruby-on-rails rspec devise

我遇到的问题是我正在编写一个rspec功能测试,该测试使用设计对应用程序进行身份验证并创建记录。

当点击提交创建记录时,在重定向时,我退出了我的会话。

我似乎无法在日志文件中找到任何奇怪的内容,我可以使用selenium-webdriver和chromedriver-helper重现此问题。

我想知道是否有其他人遇到过这个问题以及你如何解决它。

我的环境:

  • rails 4.2.6
  • 设计3.5.6
  • selenium-webdriver 2.53.0
  • chromedriver-helper 1.0.0
  • rspec-rails 3.4.2
  • capybara 2.7.0

规格/支持/ devise.rb

RSpec.configure do |config|
  config.include Devise::TestHelpers, type: :controller
  config.include Devise::TestHelpers, type: :view
end

规格/特征/笔记/ create_note_spec.rb:

require 'rails_helper'

feature 'note management' do
  scenario 'user can create a new note' do
    visit root_path
    click_link 'Sign In'
    fill_in 'user_email', with: user.email
    fill_in 'user_password', with: CONFIG[:test_user_password]
    click_button 'Log in'
    click_link 'Notes'
    click_link 'New Note'
    fill_in 'note_title', with: Faker::Lorem.word
    fill_in 'note_content', with: Faker::Lorem.paragraph
    click_button 'Create Note'
    expect(page).to have_content 'Note created'
  end
end

1 个答案:

答案 0 :(得分:0)

我认为您需要启用Warden测试模式才能完成所有工作。

选中此wiki page