Sha256: b8c53ed4ae1e9476d2d0d2b89874b5732b44bf82fc95623b5598e85c075461d3

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require 'active_record'
require 'fileutils'
require 'logger'
require 'yaml'

begin
  FileUtils.mkdir 'log'
rescue Errno::EEXIST
end

log_file                             = File.join(Dir.pwd, 'log', 'activerecord.log')
rails_database_yaml_file_path        = File.join(Dir.pwd, 'config', 'database.yml')
rails_engine_database_yaml_file_path = File.join(Dir.pwd,
                                                 'spec',
                                                 'dummy',
                                                 'config',
                                                 'database.yml')
database_yaml_file_path              = if File.exist? rails_engine_database_yaml_file_path
                                         rails_engine_database_yaml_file_path
                                       else
                                         rails_database_yaml_file_path
                                       end
connection_info                      = YAML.load_file(database_yaml_file_path)['test']

ActiveRecord::Base.logger = Logger.new(log_file)
ActiveRecord::Base.establish_connection(connection_info)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspeckled-2.1.1 lib/rspeckled/spec_helpers/active_record_connection_setup.rb
rspeckled-2.1.0 lib/rspeckled/spec_helpers/active_record_connection_setup.rb