Commit 81976dd
Changed files (3)
spec/rails_helper.rb
@@ -34,7 +34,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
@@ -50,4 +50,23 @@ RSpec.configure do |config|
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
config.infer_spec_type_from_file_location!
+ 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
Gemfile
@@ -49,5 +49,6 @@ group :development, :test do
gem 'poltergeist'
gem 'factory_girl_rails'
gem 'ffaker'
+ gem 'database_cleaner'
end
Gemfile.lock
@@ -59,6 +59,7 @@ GEM
execjs
coffee-script-source (1.8.0)
columnize (0.9.0)
+ database_cleaner (1.4.0)
debug_inspector (0.0.2)
debugger-linecache (1.2.0)
diff-lcs (1.2.5)
@@ -226,6 +227,7 @@ PLATFORMS
DEPENDENCIES
byebug
coffee-rails (~> 4.1.0)
+ database_cleaner
email_validator
factory_girl_rails
ffaker