This is an improve version of the rspec-precommit from markhazlett
We add this features
- Show what specs are failing
- Add Color to the results
- Add Loading while waiting to finish the rspec
- Add RAILS_ENV=test to rspec command
ToDo
- Show pending specs
The scripts will invoke your rspec tests and not allow you to commit unless they are all passing/pending. If any failures occur then it will stop the commit from going through to allow you to fix your tests.
- Copy the rspec-precommit file into your
.git/hooks
directory. - Call the rspec-precommit from the pre-commit
ruby .git/hooks/rspec-precommit
(example in pre-commit file in repo) - Add rspec_results.html to your .gitignore file
- Try to perform a
git commit -m
with a failing Rspect test. - To skip validation use
--no-verify
If the hook is not getting executed, call chmod +x .git/hooks/rspec-precommit
to make it so!