lib/rspeckled/plugins/database_cleaner.rb in rspeckled-0.0.30 vs lib/rspeckled/plugins/database_cleaner.rb in rspeckled-0.0.31
- old
+ new
@@ -1,6 +1,7 @@
# frozen_string_literal: true
+
##############################################################################
# Database Cleaner Plugin
##############################################################################
begin
@@ -17,21 +18,20 @@
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation, :except => %w{ar_internal_metadata})
end
config.around(:each) do |example|
- DatabaseCleaner.strategy = :transaction
+ DatabaseCleaner.strategy = if example.metadata[:js]
+ [:truncation, :except => %w{ar_internal_metadata}]
+ else
+ :transaction
+ end
+
DatabaseCleaner.start
example.run
DatabaseCleaner.clean
- end
-
- config.around(:each, :js => true) do |example|
- DatabaseCleaner.strategy = [:truncation, :except => %w{ar_internal_metadata}]
-
- example.run
end
end
if defined? RSpec::Rails
RSpec.configure do |config|