diff --git a/spec/beef/modules/debug/test_beef_debugs_spec.rb b/spec/beef/modules/debug/test_beef_debugs_spec.rb index 91cb44793..0821f8478 100644 --- a/spec/beef/modules/debug/test_beef_debugs_spec.rb +++ b/spec/beef/modules/debug/test_beef_debugs_spec.rb @@ -10,6 +10,8 @@ require_relative '../../../spec_helper' require_relative '../../../support/constants' require_relative '../../../support/beef_test' +MUTEX = Mutex.new + RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do before(:all) do # Grab config and set creds in variables for ease of access @@ -19,7 +21,11 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do print_info 'Loading database' db_file = @config.get('beef.database.file') print_info 'Resetting the database for BeEF.' - File.delete(db_file) if File.exist?(db_file) + + if ENV['RESET_DB'] + File.delete(db_file) if File.exist?(db_file) + end + @username = @config.get('beef.credentials.user') @password = @config.get('beef.credentials.passwd') @@ -48,8 +54,12 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do end ActiveRecord::Migrator.migrations_paths = [File.join('core', 'main', 'ar-migrations')] - context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths) - ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration, context.internal_metadata).migrate if context.needs_migration? + MUTEX.synchronize do + context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths) + if context.needs_migration? + ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration, context.internal_metadata).migrate + end + end BeEF::Core::Migration.instance.update_db!