main
 1#!/bin/sh
 2
 3# bin/test: Run test suite for application. Optionally pass in a path to an
 4#              individual test file to run a single test.
 5
 6set -e
 7
 8cd "$(dirname "$0")/.."
 9
10[ -z "$DEBUG" ] || set -x
11
12RACK_ROOT="$(cd "$(dirname "$0")"/.. && pwd)"
13export RACK_ROOT
14
15if [ "$RAILS_ENV" = "test" ] || [ "$RACK_ENV" = "test" ]; then
16  # if executed and the environment is already set to `test`, then we want a
17  # clean from scratch application. This almost always means a ci environment,
18  # since we set the environment to `test` directly in `bin/cibuild`.
19  bin/setup
20else
21  # if the environment isn't set to `test`, set it to `test` and update the
22  # application to ensure all dependencies are met as well as any other things
23  # that need to be up to date, like db migrations. The environment not having
24  # already been set to `test` almost always means this is being called on it's
25  # own from a `development` environment.
26  export RAILS_ENV="test" RACK_ENV="test"
27
28  bin/update
29fi
30
31echo "==> Running webpack…"
32bin/webpack
33echo "==> Running tests…"
34
35if [ -n "$1" ]; then
36  # pass arguments to test call. This is useful for calling a single test.
37  bin/rspec "$1"
38else
39  bin/rake test
40  bin/yarn test
41fi