Sha256: bce650b7f7c6fcbeb8967b7cf7fe8fb056bacd368acec27a5c9787e1725a8e24

Contents?: true

Size: 652 Bytes

Versions: 5

Compression:

Stored size: 652 Bytes

Contents

require 'sqlite3'

require 'remote_db'

module TestDb
  include RemoteDb::Concerns::Configurable

  def self.require_models
    load File.join([File.dirname(__FILE__), 'person.rb'])
  end

  def self.prepare_test_db!
    db_file = configuration.database
    db = SQLite3::Database.new db_file
    db.execute 'CREATE TABLE IF NOT EXISTS persons (id INTEGER PRIMARY KEY, first_name TEXT, last_name TEXT)'
    db.execute "INSERT INTO persons(id, first_name, last_name) VALUES (1, 'John', 'Smith')"
  end

  def self.cleanup_test_db!
    db_file = configuration.database
    if db_file && File.exists?(db_file)
      File.unlink(db_file)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
remote_db-0.0.9 spec/test_db/test_db.rb
remote_db-0.0.8 spec/test_db/test_db.rb
remote_db-0.0.7 spec/test_db/test_db.rb
remote_db-0.0.6 spec/test_db/test_db.rb
remote_db-0.0.5 spec/test_db/test_db.rb