【发布时间】:2016-05-09 15:08:31
【问题描述】:
我在编写 rspec 功能测试时遇到问题,该测试使用设计对应用程序进行身份验证并创建记录。
点击提交以创建记录时,在重定向时,我已退出会话。
我似乎在日志文件中找不到任何奇怪的东西,我能够使用 selenium-webdriver 和 chromedriver-helper 重现此问题。
我想知道是否有其他人遇到过这个问题以及您如何解决它。
我的环境:
- 导轨 4.2.6
- 设计 3.5.6
- selenium-webdriver 2.53.0
- chromedriver-helper 1.0.0
- rspec-rails 3.4.2
- 水豚2.7.0
spec/support/devise.rb
RSpec.configure do |config|
config.include Devise::TestHelpers, type: :controller
config.include Devise::TestHelpers, type: :view
end
spec/features/notes/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
【问题讨论】:
标签: ruby-on-rails rspec devise