From d5719d2f3ed48a75dc7039ebb225b4b0d44a0b54 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Thu, 18 Jan 2024 22:51:07 +0100 Subject: [PATCH] remove debug --- .gitignore | 1 + spec/spec_helper.rb | 12 ++++++------ test/test_helper.rb | 9 ++++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 2f6900c..e9f555f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ tmp/ .ruby-* *.iml coverage/ +.env diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2466790..2396753 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -76,15 +76,14 @@ def sqlite? # see: https://relishapp.com/rspec/rspec-core/v/3-8/docs/configuration/zero-monkey-patching-mode config.disable_monkey_patching! - if sqlite? + config.before(:suite) do - ENV['FLOCK_DIR'] = Dir.mktmpdir + ENV['FLOCK_DIR'] = Dir.mktmpdir if sqlite? end config.after(:suite) do - FileUtils.remove_entry_secure ENV['FLOCK_DIR'] + FileUtils.remove_entry_secure( ENV['FLOCK_DIR']) if sqlite? end - end end # Configure parallel specs @@ -94,10 +93,10 @@ def sqlite? # See: https://github.com/ClosureTree/with_advisory_lock ENV['WITH_ADVISORY_LOCK_PREFIX'] ||= SecureRandom.hex -ActiveRecord::Base.connection.recreate_database("closure_tree_test") unless sqlite? -puts "Testing with #{env_db} database, ActiveRecord #{ActiveRecord.gem_version} and #{RUBY_ENGINE} #{RUBY_ENGINE_VERSION} as #{RUBY_VERSION}" # Require our gem require 'closure_tree' +ActiveRecord::Tasks::DatabaseTasks.create_current('default_env') +ActiveRecord::Tasks::DatabaseTasks.create_current('secondary_env') # Load test helpers require_relative 'support/schema' @@ -105,3 +104,4 @@ def sqlite? require_relative 'support/helpers' require_relative 'support/exceed_query_limit' require_relative 'support/query_counter' +puts "Testing with #{env_db} database, ActiveRecord #{ActiveRecord.gem_version} and #{RUBY_ENGINE} #{RUBY_ENGINE_VERSION} as #{RUBY_VERSION}" diff --git a/test/test_helper.rb b/test/test_helper.rb index cdb6c6b..42fddf9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -23,7 +23,6 @@ ENV['WITH_ADVISORY_LOCK_PREFIX'] ||= SecureRandom.hex - def env_db @env_db ||= ActiveRecord::Base.connection_db_config.adapter.to_sym end @@ -37,9 +36,9 @@ def sqlite? env_db == :sqlite3 end -puts "Testing with #{env_db} database, ActiveRecord #{ActiveRecord.gem_version} and #{RUBY_ENGINE} #{RUBY_ENGINE_VERSION} as #{RUBY_VERSION}" DatabaseCleaner.strategy = :truncation +DatabaseCleaner.allow_remote_database_url = true module Minitest class Spec @@ -61,6 +60,10 @@ class Spec Thread.abort_on_exception = true require 'closure_tree' +ActiveRecord::Tasks::DatabaseTasks.create_current('default_env') +ActiveRecord::Tasks::DatabaseTasks.create_current('secondary_env') + require_relative '../spec/support/schema' require_relative '../spec/support/models' -ActiveRecord::Base.connection.recreate_database('closure_tree_test') unless sqlite? + +puts "Testing with #{env_db} database, ActiveRecord #{ActiveRecord.gem_version} and #{RUBY_ENGINE} #{RUBY_ENGINE_VERSION} as #{RUBY_VERSION}"