Skip to content

Instantly share code, notes, and snippets.

@pelf
Last active July 24, 2017 17:07
Show Gist options
  • Save pelf/59c28051defb64beb4a27e161dc0e8fd to your computer and use it in GitHub Desktop.
Save pelf/59c28051defb64beb4a27e161dc0e8fd to your computer and use it in GitHub Desktop.
Handy git pre-push script for ruby specs
#!/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