Skip to content

Instantly share code, notes, and snippets.

@hammeiam
Last active October 2, 2015 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hammeiam/07ff08a821e51b21cc4a to your computer and use it in GitHub Desktop.
Save hammeiam/07ff08a821e51b21cc4a to your computer and use it in GitHub Desktop.
# Love running tests but hate having to check and see if they're finished?
# Add rspek to your .bash_profile to get a desktop notification (plus optional sound) when your tests are done!
# Before using, make sure to grab the dependency with `brew install terminal-notifier` or `gem install terminal-notifier`
#
# USE:
# rspek -f // run all tests in /spec. `--fail-fast` is set by default, `-f` disables it
# rspek /spec/features -q // run all features, no audio notification
# rspek some_file_spec.rb:50 // run one test
function rspek() {
local LOCATION="${1:-spec}"
local FAILFAST="--fail-fast"
local TONE=
local MESSAGE=
for arg in "$@"
do
case $arg in
"-f" )
FAILFAST=;;
"-q" )
local QUIET=true;;
esac
done
if ! bundle exec rspec "$LOCATION" --format documentation "$FAILFAST"; then
MESSAGE="TEST FAILED"; TONE="Sosumi"
else
MESSAGE="TEST PASSED"; TONE="Glass"
fi
local CMD=(terminal-notifier -message "$MESSAGE" -title "rspec says...")
[[ -z "$QUIET" ]] && CMD+=(-sound "$TONE")
"${CMD[@]}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment