How can I add a pre-commit hook that will run my rspec tests, and if any failure fails to complete the commit. I can run the tests, but not prevent the commit when they fail.
I copied .git/hooks/pre-commit.sample to .git/hooks/pre-commit
I added an rspec spec at the bottom.
Testing is performed as part of a commit ... but a failure does not stop completing a commit.
$ git commit -m'test' ....................................................................................................F............. Failures: 1) Link Good url SHOULD be valid Failure/Error: expect(link.valid_get?).to be false
Perhaps I need another way to run rspec tests that will raise the non-zero error that I need?
It is currently located below:
... echo echo " git config hooks.allownonascii true" echo exit 1 fi rspec spec exec git diff-index --check --cached $against --
I do all this in a branch (and not in a master). I didn't know if that mattered.
source share