【发布时间】:2014-09-20 21:20:33
【问题描述】:
如何添加一个预提交挂钩来运行我的 rspec 测试,如果有任何失败,将不会完成提交。我可以让测试运行,但不能阻止任何失败的提交
我已将.git/hooks/pre-commit.sample 复制到.git/hooks/pre-commit
我在底部附近添加了rspec spec。
测试作为提交的一部分运行...但失败不会阻止提交完成。
$ git commit -m'test'
....................................................................................................F.............
Failures:
1) Link Good url SHOULD be valid
Failure/Error: expect(link.valid_get?).to be false #true
expected false
got true
# ./spec/models/link_spec.rb:26:in `block (2 levels) in <top (required)>'
Finished in 32.78 seconds (files took 3.58 seconds to load)
114 examples, 1 failure
Failed examples:
rspec ./spec/models/link_spec.rb:24 # Link Good url SHOULD be valid
[79230846_hook_to_run_tests 6c09570] test
1 file changed, 1 insertion(+)
create mode 100644 x.x
也许我需要一种不同的方式来运行 rspec 测试,这会引发我需要的非零错误?
目前位于底部:
...
echo
echo " git config hooks.allownonascii true"
echo
exit 1
fi
rspec spec
exec git diff-index --check --cached $against --
我在一个分支(不是主人)中做这一切。不知道这是否相关。
【问题讨论】:
标签: ruby-on-rails git rspec githooks pre-commit-hook