Sha256: c8fb4e39cab4d7e3037ba4446724ffbcb4ba1041689fa5e63445969da6ea91b9

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'gemika'
require 'combustion'
require 'yaml'

Dir["#{File.dirname(__FILE__)}/extensions/*.rb"].sort.each { |f| require f }
Dir["#{File.dirname(__FILE__)}/support/*.rb"].sort.each { |f| require f }
READ_DATABASE_CONFIG_LOCATION = 'spec/internal/config/database.ci.yml'
WRITE_DATABASE_CONFIG_LOCATION = 'spec/internal/config/database.yml'

def adapter_name
  if Gemika::Env.gem?('mysql2')
    'mysql'
  else
    'postgresql'
  end
end

def database_config_from_gems(file_location)
  config = YAML.load_file(file_location)
  data = config.slice(adapter_name)
  { Rails.env.to_s => data }
end

original_env = Rails.env

puts database_config_from_gems(READ_DATABASE_CONFIG_LOCATION)
File.write(
  WRITE_DATABASE_CONFIG_LOCATION,
  database_config_from_gems(READ_DATABASE_CONFIG_LOCATION).to_yaml
)

Rails.env = adapter_name
database = Gemika::Database.new
database.connect

Gemika::RSpec.configure_clean_database_before_example
Rails.env = original_env

begin
  Combustion.initialize! :active_record
rescue ActiveRecord::RecordNotUnique
  # noop
end

RSpec.configure do |config|
  config.before do
    DatabaseCleaner.clean
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
temporal_tables-3.0.2 spec/spec_helper.rb
temporal_tables-3.0.1 spec/spec_helper.rb
temporal_tables-3.0.0 spec/spec_helper.rb
temporal_tables-3.0.0.pre.rc.1 spec/spec_helper.rb