#!/usr/bin/env bash

set -e

directory=$1

cd example
bundle
yarn install

# test a normal test run
bundle exec rake db:test:prepare
bundle exec rake cypress:run

# test that passing options works (by printing help)
if ! bundle exec rake cypress:run CYPRESS_RAILS_CYPRESS_OPTS="-h" | grep -q "Usage: cypress run \[options\]"; then
  echo "Failed to pass options to cypress run"
  exit 1
fi

