A platform for community discussion. Free, open, simple.
# frozen_string_literal: true
RSpec.shared_context "with intermediate database" do
around do |example|
Dir.mktmpdir do |dir|
db_path = File.join(dir, "intermediate.db")
Migrations::Database.migrate(
db_path,
migrations_path: Migrations::Database::INTERMEDIATE_DB_SCHEMA_PATH,
)
@db = Migrations::Database.connect(db_path)
Migrations::Database::IntermediateDB.setup(@db)
example.run
ensure
Migrations::Database::IntermediateDB.setup(nil)
end
end
def rows(table)
[].tap { |out| @db.query("SELECT * FROM #{table}") { |row| out << row } }
end
end