Use DatabaseCleaner
This commit is contained in:
parent
8d2e1edaea
commit
2c911d9cde
2
Gemfile
2
Gemfile
|
@ -82,6 +82,8 @@ group :development do
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
|
gem 'database_cleaner', '~> 1.7'
|
||||||
|
|
||||||
# Code coverage for Ruby 1.9+ with a powerful configuration library
|
# Code coverage for Ruby 1.9+ with a powerful configuration library
|
||||||
# and automatic merging of coverage across test suites.
|
# and automatic merging of coverage across test suites.
|
||||||
gem 'simplecov', '~> 0.16', require: false
|
gem 'simplecov', '~> 0.16', require: false
|
||||||
|
|
|
@ -52,6 +52,7 @@ GEM
|
||||||
coderay (1.1.2)
|
coderay (1.1.2)
|
||||||
concurrent-ruby (1.1.3)
|
concurrent-ruby (1.1.3)
|
||||||
crass (1.0.4)
|
crass (1.0.4)
|
||||||
|
database_cleaner (1.7.0)
|
||||||
diff-lcs (1.3)
|
diff-lcs (1.3)
|
||||||
docile (1.3.1)
|
docile (1.3.1)
|
||||||
erubi (1.7.1)
|
erubi (1.7.1)
|
||||||
|
@ -214,6 +215,7 @@ PLATFORMS
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
bootsnap (>= 1.1.0)
|
bootsnap (>= 1.1.0)
|
||||||
byebug
|
byebug
|
||||||
|
database_cleaner (~> 1.7)
|
||||||
factory_bot_rails (~> 4.10)
|
factory_bot_rails (~> 4.10)
|
||||||
faker (~> 1.8)
|
faker (~> 1.8)
|
||||||
listen (>= 3.0.5, < 3.2)
|
listen (>= 3.0.5, < 3.2)
|
||||||
|
|
|
@ -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 New Issue