rails_template/script/test

27 lines
715 B
Bash
Executable File

#!/usr/bin/env bash
# script/test: Run test suite for application. Optionally pass in a path to an
# individual test file to run a single test.
set -e
# cd to project root
cd "$(dirname "$0")/.."
export PROJECT_NAME="app_test" RAILS_ENV="test" RACK_ENV="test"
printf "\n===> Migrating database ...\n";
docker-compose run -e RAILS_ENV=$RAILS_ENV app rails db:create db:schema:load db:migrate
printf "\n===> Running tests ...\n";
if [ -n "$1" ]; then
docker-compose run -e RAILS_ENV=$RAILS_ENV app rspec "$1"
else
docker-compose run -e RAILS_ENV=$RAILS_ENV app rspec
fi
printf "\n===> Removing app instances ...\n";
docker-compose stop
docker rm $(docker ps -a -q --filter="name=*_app_run*")