Bladeren bron

Remove database_cleaner gem

In Rails 5.1 transactional tests share the same connection id between
the webserver and test runner. This removes the need for special cleanup
strategies.

This speeds up the tests significantly, before:
```
Finished in 3 minutes 30.3 seconds (files took 5.46 seconds to load)
```

After:
```
Finished in 1 minute 41.61 seconds (files took 5.45 seconds to load)
```

https://github.com/rails/rails/pull/28083
Dominik Sander 8 jaren geleden
bovenliggende
commit
df6fa9f9d4
4 gewijzigde bestanden met toevoegingen van 1 en 11 verwijderingen
  1. 0 1
      Gemfile
  2. 0 2
      Gemfile.lock
  3. 0 7
      spec/capybara_helper.rb
  4. 1 1
      spec/rails_helper.rb

+ 0 - 1
Gemfile

@@ -163,7 +163,6 @@ group :development do
     gem 'shoulda-matchers'
     gem 'shoulda-matchers'
     gem 'vcr'
     gem 'vcr'
     gem 'webmock', '~> 1.17.4', require: false
     gem 'webmock', '~> 1.17.4', require: false
-    gem 'database_cleaner', '~> 1.5.3'
   end
   end
 end
 end
 
 

+ 0 - 2
Gemfile.lock

@@ -179,7 +179,6 @@ GEM
     crack (0.4.2)
     crack (0.4.2)
       safe_yaml (~> 1.0.0)
       safe_yaml (~> 1.0.0)
     daemons (1.1.9)
     daemons (1.1.9)
-    database_cleaner (1.5.3)
     debug_inspector (0.0.2)
     debug_inspector (0.0.2)
     delorean (2.1.0)
     delorean (2.1.0)
       chronic
       chronic
@@ -620,7 +619,6 @@ DEPENDENCIES
   coffee-rails (~> 4.2)
   coffee-rails (~> 4.2)
   coveralls (~> 0.7.4)
   coveralls (~> 0.7.4)
   daemons (~> 1.1.9)
   daemons (~> 1.1.9)
-  database_cleaner (~> 1.5.3)
   delayed_job!
   delayed_job!
   delayed_job_active_record!
   delayed_job_active_record!
   delorean
   delorean

+ 0 - 7
spec/capybara_helper.rb

@@ -19,16 +19,9 @@ RSpec.configure do |config|
 
 
   config.before(:suite) do
   config.before(:suite) do
     Warden.test_mode!
     Warden.test_mode!
-    DatabaseCleaner.clean_with(:truncation)
-  end
-
-  config.before(:each) do |example|
-    DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
-    DatabaseCleaner.start
   end
   end
 
 
   config.after(:each) do
   config.after(:each) do
-    DatabaseCleaner.clean
     Warden.test_reset!
     Warden.test_reset!
   end
   end
 end
 end

+ 1 - 1
spec/rails_helper.rb

@@ -38,7 +38,7 @@ RSpec.configure do |config|
   # If you're not using ActiveRecord, or you'd prefer not to run each of your
   # If you're not using ActiveRecord, or you'd prefer not to run each of your
   # examples within a transaction, remove the following line or assign false
   # examples within a transaction, remove the following line or assign false
   # instead of true.
   # instead of true.
-  config.use_transactional_fixtures = ENV['RSPEC_TASK'] == 'spec:nofeatures'
+  config.use_transactional_fixtures = true
 
 
   # rspec-rails 3 will no longer automatically infer an example group's spec type
   # rspec-rails 3 will no longer automatically infer an example group's spec type
   # from the file location. You can explicitly opt-in to this feature using this
   # from the file location. You can explicitly opt-in to this feature using this