Skip to content

Instantly share code, notes, and snippets.

@sebackend
Last active May 16, 2018 15:26
Show Gist options
  • Save sebackend/743378e474a87c450b061045ee250a50 to your computer and use it in GitHub Desktop.
Save sebackend/743378e474a87c450b061045ee250a50 to your computer and use it in GitHub Desktop.
git pre-push hook for rspec
cd /path/to/your/repo
curl https://gist.githubusercontent.com/smezae/743378e474a87c450b061045ee250a50/raw/71ee093163ea8f7c73f1a7217f6416ac7092d3ba/pre-push.sh > .git/hooks/pre-push
chmod u+x .git/hooks/pre-push
#!/bin/env bash
echo "Running RSpec"
bundle exec rspec spec
spec=$?
if [ $spec -eq 0 ] then
echo -en "\\033[32mTests are green, pushing...\\033[0;39m\n"
exit 0
else
echo -en "\\033[1;31mCannot push, tests are failing. Use --no-verify to force push.\\033[0;39m\n"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment