forked from sds/overcommit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_flag_spec.rb
42 lines (37 loc) · 1.09 KB
/
run_flag_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'spec_helper'
describe 'overcommit --run' do
subject { shell(%w[overcommit --run]) }
context 'when using an existing pre-commit hook script' do
if Overcommit::OS.windows?
let(:script_name) { 'test-script.bat' }
let(:script_contents) { 'exit 0' }
else
let(:script_name) { 'test-script' }
let(:script_contents) { "#!/bin/bash\nexit 0" }
end
let(:script_path) { ".#{Overcommit::OS::SEPARATOR}#{script_name}" }
let(:config) do
{
'PreCommit' => {
'MyHook' => {
'enabled' => true,
'required_executable' => script_path,
}
}
}
end
around do |example|
repo do
File.open('.overcommit.yml', 'w') { |f| f.puts(config.to_yaml) }
echo(script_contents, script_path)
`git add #{script_path}`
FileUtils.chmod(0o755, script_path)
example.run
end
end
it 'completes successfully without blocking' do
wait_until(timeout: 10) { subject } # Need to wait long time for JRuby startup
subject.status.should == 0
end
end
end