diff options
author | Jared Norman <jared@super.gd> | 2019-01-09 16:38:01 -0800 |
---|---|---|
committer | Jared Norman <jared@super.gd> | 2019-01-09 16:38:01 -0800 |
commit | b1d9f590860a74831d594dec5464b67f3aa6e18f (patch) | |
tree | 6edd439f7f85a57df8ebcc5a0d784bfc47828787 /spec | |
parent | f0de9ce17896903d1436b122d52fc4b185c0b477 (diff) |
Use DatabaseCleaner to keep the database clean
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec_helper.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7a7f305..d79d49a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,7 @@ ENV['RAILS_ENV'] ||= 'test' require "bundler/setup" +require "database_cleaner" begin require File.expand_path('../dummy/config/environment', __FILE__) @@ -21,4 +22,17 @@ RSpec.configure do |config| config.order = "random" Kernel.srand config.seed + + config.before :suite do + DatabaseCleaner.strategy = :transaction + end + + config.before :each do + DatabaseCleaner.start + end + + # After each spec clean the database. + config.after :each do + DatabaseCleaner.clean + end end |