Improvements in the DatabaseCleaner
Move all what is related to the DatabaseCleaner to the database_cleaner.rb file. Load the seeds only when they have been deleted and not before every test.
This commit is contained in:
parent
052cfebf4e
commit
7ebf44d1e4
2 changed files with 7 additions and 11 deletions
|
|
@ -55,13 +55,6 @@ RSpec.configure do |config|
|
||||||
# --seed 1234
|
# --seed 1234
|
||||||
config.order = 'random'
|
config.order = 'random'
|
||||||
|
|
||||||
config.around(:each) do |example|
|
|
||||||
DatabaseCleaner.cleaning do
|
|
||||||
Rails.application.load_seed
|
|
||||||
example.run
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# poltergeist as a underlying mech for Capybara
|
# poltergeist as a underlying mech for Capybara
|
||||||
Capybara.javascript_driver = :poltergeist
|
Capybara.javascript_driver = :poltergeist
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.before(:suite) do
|
config.before(:suite) do
|
||||||
DatabaseCleaner.clean_with(:truncation)
|
DatabaseCleaner.clean_with(:truncation)
|
||||||
|
Rails.application.load_seed
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before(:each) do
|
config.before(:each) do |example|
|
||||||
DatabaseCleaner.strategy = :transaction
|
DatabaseCleaner.strategy = (example.metadata[:js] == true) ? :truncation : :transaction
|
||||||
|
DatabaseCleaner.start
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before(:each, js: true) do
|
config.after(:each) do |example|
|
||||||
DatabaseCleaner.strategy = :truncation
|
DatabaseCleaner.clean
|
||||||
|
Rails.application.load_seed if example.metadata[:js] == true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue