Use DatabaseCleaner
This commit is contained in:
parent
8d2e1edaea
commit
2c911d9cde
3 changed files with 18 additions and 0 deletions
2
Gemfile
2
Gemfile
|
@ -82,6 +82,8 @@ group :development do
|
|||
end
|
||||
|
||||
group :test do
|
||||
gem 'database_cleaner', '~> 1.7'
|
||||
|
||||
# Code coverage for Ruby 1.9+ with a powerful configuration library
|
||||
# and automatic merging of coverage across test suites.
|
||||
gem 'simplecov', '~> 0.16', require: false
|
||||
|
|
|
@ -52,6 +52,7 @@ GEM
|
|||
coderay (1.1.2)
|
||||
concurrent-ruby (1.1.3)
|
||||
crass (1.0.4)
|
||||
database_cleaner (1.7.0)
|
||||
diff-lcs (1.3)
|
||||
docile (1.3.1)
|
||||
erubi (1.7.1)
|
||||
|
@ -214,6 +215,7 @@ PLATFORMS
|
|||
DEPENDENCIES
|
||||
bootsnap (>= 1.1.0)
|
||||
byebug
|
||||
database_cleaner (~> 1.7)
|
||||
factory_bot_rails (~> 4.10)
|
||||
faker (~> 1.8)
|
||||
listen (>= 3.0.5, < 3.2)
|
||||
|
|
14
spec/support/database_cleaner.rb
Normal file
14
spec/support/database_cleaner.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.before :suite do
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
DatabaseCleaner.clean_with :truncation
|
||||
end
|
||||
|
||||
config.around do |example|
|
||||
DatabaseCleaner.cleaning do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
end
|
Reference in a new issue