Sha256: 6c1584a7ec3783d95c2c030bec62ad84dfd43c0a66d362ccef33708a96e8d91f

Contents?: true

Size: 709 Bytes

Versions: 2

Compression:

Stored size: 709 Bytes

Contents

class Baza::InfoActiveRecordMysql2
  attr_reader :db

  def self.connection
    require "active_record"

    @conn_pool ||= ::ActiveRecord::Base.establish_connection(
      adapter: "mysql2",
      host: "localhost",
      database: "baza-test",
      username: "baza-test",
      password: "BBH7djRUKzL5nmG3"
    )
    @conn ||= @conn_pool.connection

    return {pool: @conn_pool, conn: @conn}
  end

  def initialize(args = {})
    data = Baza::InfoActiveRecordMysql2.connection

    @db = Baza::Db.new({
      type: :active_record,
      conn: data[:conn]
    }.merge(args))
  end

  def before
    @db.tables.list.each do |name, table|
      table.drop
    end
  end

  def after
    @db.close
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
baza-0.0.19 spec/info_active_record_mysql2.rb
baza-0.0.18 spec/info_active_record_mysql2.rb