Mic*_*ant 8 git rspec ruby-on-rails pre-commit-hook githooks
如何添加将运行我的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
Run Code Online (Sandbox Code Playgroud)
也许我需要一种不同的方式来运行rspec测试,这将提高我需要的非零错误?
目前它位于底部:
...
echo
echo " git config hooks.allownonascii true"
echo
exit 1
fi
rspec spec
exec git diff-index --check --cached $against --
Run Code Online (Sandbox Code Playgroud)
我在一个分支(不是主人)中做这一切.不知道那是否相关.
Mic*_*ant 10
我发现使用了
exec rspec spec
Run Code Online (Sandbox Code Playgroud)
在
.git/hooks/pre-commit
Run Code Online (Sandbox Code Playgroud)
给了我所需的功能 -
提交尝试触发rspec测试运行,如果所有rspec测试都通过,则提交仅完成.
| 归档时间: |
|
| 查看次数: |
1713 次 |
| 最近记录: |