Sha256: 0c6ebee07ee70a8e9c944f0b5aa7999394f98cb5a3c20937c4fc63f0f544b5f5

Contents?: true

Size: 751 Bytes

Versions: 15

Compression:

Stored size: 751 Bytes

Contents

class Baza::InfoActiveRecordSqlite3
  attr_reader :db

  def self.connection
    require "active_record"

    path = "#{Dir.tmpdir}/baza_sqlite3_test_#{Time.now.to_f.to_s.hash}_#{Random.rand}.sqlite3"
    File.unlink(path) if File.exist?(path)

    @conn_pool ||= ::ActiveRecord::Base.establish_connection(
      adapter: "sqlite3",
      database: path
    )
    @conn ||= @conn_pool.connection

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

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

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

  def before
    @db.tables.list(&:drop)
  end

  def after
    @db.close
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
baza-0.0.35 spec/info_active_record_sqlite3.rb
baza-0.0.34 spec/info_active_record_sqlite3.rb
baza-0.0.33 spec/info_active_record_sqlite3.rb
baza-0.0.32 spec/info_active_record_sqlite3.rb
baza-0.0.31 spec/info_active_record_sqlite3.rb
baza-0.0.30 spec/info_active_record_sqlite3.rb
baza-0.0.29 spec/info_active_record_sqlite3.rb
baza-0.0.28 spec/info_active_record_sqlite3.rb
baza-0.0.27 spec/info_active_record_sqlite3.rb
baza-0.0.26 spec/info_active_record_sqlite3.rb
baza-0.0.25 spec/info_active_record_sqlite3.rb
baza-0.0.24 spec/info_active_record_sqlite3.rb
baza-0.0.23 spec/info_active_record_sqlite3.rb
baza-0.0.22 spec/info_active_record_sqlite3.rb
baza-0.0.21 spec/info_active_record_sqlite3.rb