Last active
July 24, 2017 17:07
-
-
Save pelf/59c28051defb64beb4a27e161dc0e8fd to your computer and use it in GitHub Desktop.
Handy git pre-push script for ruby specs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "π Checking for focus: true..." | |
# Check for focus in spec files | |
grep -r --include \*_spec.rb "focus:" spec || grep -r --include \*_spec.rb ":focus" spec | |
if [[ $? == 0 ]] | |
then | |
echo >&2 "β Found focus in spec file, not pushing" | |
exit 1 | |
fi | |
echo "β None found. All good!" | |
echo "π Checking for binding.pry..." | |
# Check for binding.pry | |
grep -r --include \*.rb "binding.pry" . | |
if [[ $? == 0 ]] | |
then | |
echo >&2 "β Found binding.pry, not pushing" | |
exit 1 | |
fi | |
echo "β None found. All good!" | |
echo "π Checking vcr record: setting..." | |
# Check for record setting in spec_helper.rb or vcr.rb | |
grep -r '^ *[^#] *record:.*:new_episodes' spec/spec_helper.rb spec/support/vcr.rb | |
if [[ $? == 0 ]] | |
then | |
echo >&2 "β Found bad vcr setting, not pushing" | |
exit 1 | |
fi | |
echo "β All good!" | |
echo "π Making sure tests pass..." | |
bundle exec rspec > /dev/null | |
if [ $? -ne 0 ]; then | |
echo "β Test suite failed" | |
exit 1 | |
fi | |
echo "β Test suite successful. All good!" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment