forked from sds/overcommit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisable_overcommit_spec.rb
55 lines (43 loc) · 1.3 KB
/
disable_overcommit_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
43
44
45
46
47
48
49
50
51
52
53
54
55
# frozen_string_literal: true
require 'spec_helper'
describe 'disabling Overcommit' do
subject { shell(%w[git commit --allow-empty -m Test]) }
around do |example|
repo do
`overcommit --install > #{File::NULL}`
Overcommit::Utils.with_environment('OVERCOMMIT_DISABLE' => overcommit_disable) do
touch 'blah'
`git add blah`
example.run
end
end
end
context 'when the OVERCOMMIT_DISABLE environment variable is set' do
let(:overcommit_disable) { '1' }
it 'exits successfully' do
subject.status.should == 0
end
it 'does not run any hooks' do
subject.stdout.should_not be_empty
subject.stderr.should_not include 'Running pre-commit hooks'
end
end
context 'when the OVERCOMMIT_DISABLE environment variable is set to zero' do
let(:overcommit_disable) { '0' }
it 'exits successfully' do
subject.status.should == 0
end
it 'runs the hooks' do
subject.stderr.should include 'Running pre-commit hooks'
end
end
context 'when the OVERCOMMIT_DISABLE environment variable is unset' do
let(:overcommit_disable) { nil }
it 'exits successfully' do
subject.status.should == 0
end
it 'runs the hooks' do
subject.stderr.should include 'Running pre-commit hooks'
end
end
end