set -e

ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
SCRIPT_DIR="${ROOT_DIR}/script"
source $SCRIPT_DIR/functions.sh

function run_specs_one_by_one {
  echo "Running each spec file, one-by-one..."

  for file in `find spec -iname '*_spec.rb'`; do
    echo "Running $PWD/$file"
    $ROOT_DIR/bin/rspec $file -b --format progress $@
  done
}

if is_mri; then
  decide_what_to_run run_specs_one_by_one $@
else
  echo "Skipping the one by one specs on non-MRI rubies"
fi
