3

I have upgraded rspec to version 3.2 and now I get a lot of database errors (Mysql2::Error: Duplicate entry) when I run the specs. The specs seems to be running in parallel. I am using the database cleaner gem (1.4.1), and it was working before the upgrade. What is happening? Here is my spec_helper file:

Capybara.javascript_driver = :webkit

RSpec.configure do |config|
  config.filter_run_excluding :broken => true
  config.filter_run :focus => true
  config.run_all_when_everything_filtered = true
  config.infer_spec_type_from_file_location!

  config.infer_base_class_for_anonymous_controllers = false

  config.order = "random"

  config.before(:suite) do
    DatabaseCleaner.strategy = :truncation
    DatabaseCleaner.strategy = :deletion, {except: %w[users]}
    DatabaseCleaner.clean_with(:truncation)
  end

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

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

end
Martin Thorsen Ranang
  • 2,394
  • 1
  • 28
  • 43
Daniel Cukier
  • 11,502
  • 15
  • 68
  • 123
  • Do you use the parallel specs gem or similar (there you set up a different database for each thread, to avoid this problem)? Do the rspec release notes mentioned anything about this? – nruth Jun 06 '15 at 17:45
  • I do not use parallel specs gem. But I was not using it before, and it was working. I moved from rspec 2.14.2 to 3.2, so there are a lot of release notes to see... – Daniel Cukier Jun 06 '15 at 18:05
  • I think the problem is in the latest version of database_cleaner gem. – Daniel Cukier Jun 06 '15 at 19:07
  • I think the problem is in the latest version of database_cleaner gem. Version 1.2.0 was working, but 1.4.1 is not – Daniel Cukier Jun 06 '15 at 19:23
  • "The specs seems to be running in parallel" - how did you reach that conclusion? – Andy Waite Jun 08 '15 at 06:45

0 Answers0