Skip to content

Commit 08cf3fc

Browse files
jawshooahsds
authored andcommitted
Use different script name and contents for Windows
1 parent eda2813 commit 08cf3fc

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

spec/integration/run_flag_spec.rb

+12-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@
44
subject { shell(%w[overcommit --run]) }
55

66
context 'when using an existing pre-commit hook script' do
7+
if Overcommit::OS.windows?
8+
let(:script_name) { 'test-script.exe' }
9+
let(:script_contents) { 'exit 0' }
10+
else
11+
let(:script_name) { 'test-script' }
12+
let(:script_contents) { "#!/bin/bash\nexit 0" }
13+
end
14+
715
let(:config) do
816
{
917
'PreCommit' => {
1018
'MyHook' => {
1119
'enabled' => true,
12-
'required_executable' => './test-script',
20+
'required_executable' => "./#{script_name}",
1321
}
1422
}
1523
}
@@ -18,9 +26,9 @@
1826
around do |example|
1927
repo do
2028
File.open('.overcommit.yml', 'w') { |f| f.puts(config.to_yaml) }
21-
echo("#!/bin/bash\nexit 0", 'test-script')
22-
`git add test-script`
23-
FileUtils.chmod(0755, 'test-script')
29+
echo(script_contents, script_name)
30+
`git add #{script_name}`
31+
FileUtils.chmod(0755, script_name)
2432
example.run
2533
end
2634
end

0 commit comments

Comments
 (0)