Skip to content

module Athena::ORM::Spec #

A set of testing utilities/types to aid in testing Athena::ORM related types.

Getting Started#

Require this module in your spec_helper.cr file.

# This also requires "spec" and "athena-spec".
require "athena-orm/spec"

Add Athena::Spec as a development dependency, then run a shards install. See the individual types for more information.

Class methods#

.migrate_database(container : ADI::ServiceContainer = ADI::ServiceContainer.new) : Nil#

Migrates the database of AORM::Bundle to the latest version, for applications using migrations, such as before the specs run:

# spec/spec_helper.cr
require "athena-orm/spec"

Spec.before_suite do
  AORM::Spec.migrate_database
end

Like orm:migrations:migrate, it only executes the migrations that haven't been executed yet, so it does nothing once the database is up to date. A migration changed after it was executed isn't executed again; revert it first, such as via orm:migrations:execute --down, or recreate the database.

The migrations are executed on the connection of container, whose closeable services are closed once they're done, returning the connection to the pool.

View source