1
votes

I am having an issue where I am writing an rspec feature test which authenticates to an application using devise and creates a record.

When hitting submit to create the record, on redirect, I am logged out of my session.

I can't seem to find anything odd in the logfile and I am able to reproduce this issue using both selenium-webdriver and chromedriver-helper.

I am wondering if anyone else has run into this issue and how you might have solved it.

My environment:

  • rails 4.2.6
  • devise 3.5.6
  • selenium-webdriver 2.53.0
  • chromedriver-helper 1.0.0
  • rspec-rails 3.4.2
  • capybara 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
1

1 Answers

0
votes

I think you need to enable Warden Test Mode to make it all work.

Check this wiki page