Capybara + Selenium acting strange

Hi all,

The following tests are successful if I run either alone, but when I run both, the second one fails. I use database_cleaner and this is my first time experiencing this despite running js:true tests in other parts of my app:

require 'spec_helper'

feature 'Users can manage profiles' do

  scenario "User can unsubscribe from email notifications", js:true do
    sign_in_default
    click_view_profile_link
    click_edit_profile #this  initiates a modal
    find('#user_receive_notifications').should  be_checked
    find('#user_receive_notifications').set false
    click_button('Update')
    click_view_profile_link
    click_edit_profile
    find('#user_receive_notifications').should_not  be_checked # this fails if I run this test second
  end

  scenario "User can update his bio", js:true do
    sign_in_default
    click_view_profile_link
    find('[data-role="bio_content"]').should have_content('')
    click_edit_profile
    fill_in 'user_note', :with => 'Updated bio' #Only types in "U" before submitting
    click_button('Update')
    click_view_profile_link
    find('[data-role="bio_content"]').should have_content('Updated bio') # this fails if I run this test second
  end

Any ideas? Thank you

@Tamas_Erdos can you post your database cleaner config and any Database cleaner setup you have?

Also, to be clear, when you run your full spec suite, do either of these tests fail?

@cpytel they both fail when I run a full rake.

Here’s my database cleaner config:

 RSpec.configure do |config|

  config.before(:suite) do
    DatabaseCleaner.clean_with(:truncation)
  end

  config.before(:each) do
    DatabaseCleaner.strategy = :transaction
  end

  config.before(:each, :js => true) do
    DatabaseCleaner.strategy = :truncation
  end

  config.before(:each) do
    DatabaseCleaner.start
  end

  config.after(:each) do
    DatabaseCleaner.clean
  end

end

Thank you