Commit 0fb2802
Changed files (4)
spec/support/database_cleaner.rb
@@ -0,0 +1,21 @@
+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
spec/rails_helper.rb
@@ -31,7 +31,7 @@ RSpec.configure do |config|
# 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
# instead of true.
- config.use_transactional_fixtures = true
+ config.use_transactional_fixtures = false
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
Gemfile
@@ -49,6 +49,7 @@ group :development, :test do
gem 'lol_dba'
gem 'rspec-rails'
gem 'factory_girl_rails'
+ gem 'database_cleaner'
# fake agent
gem 'listen'
Gemfile.lock
@@ -60,6 +60,7 @@ GEM
execjs
coffee-script-source (1.9.1)
columnize (0.9.0)
+ database_cleaner (1.4.0)
debug_inspector (0.0.2)
debugger-linecache (1.2.0)
diff-lcs (1.2.5)
@@ -239,6 +240,7 @@ DEPENDENCIES
byebug
chartkick
coffee-rails (~> 4.1.0)
+ database_cleaner
dotenv-rails
factory_girl_rails
foreman