forked from sds/overcommit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_config_spec.rb
More file actions
80 lines (68 loc) · 1.89 KB
/
git_config_spec.rb
File metadata and controls
80 lines (68 loc) · 1.89 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
require 'spec_helper'
describe Overcommit::GitConfig do
describe '.comment_character' do
subject { described_class.comment_character }
context 'with no configuration' do
it 'should be "#"' do
repo do
`git config --local core.commentchar ""`
expect(subject).to eq '#'
end
end
end
context 'with custom configuration' do
it 'should be the configured character' do
repo do
`git config --local core.commentchar x`
expect(subject).to eq 'x'
end
end
end
end
describe '.hooks_path' do
subject { described_class.hooks_path }
context 'when not explicitly set' do
around do |example|
repo do
example.run
end
end
it 'returns the default hook path' do
expect(subject).to eq File.expand_path(File.join('.git', 'hooks'))
end
end
context 'when explicitly set to an empty string' do
around do |example|
repo do
`git config --local core.hooksPath ""`
example.run
end
end
it 'returns the default hook path' do
expect(subject).to eq File.expand_path(File.join('.git', 'hooks'))
end
end
context 'when explicitly set to an absolute path' do
around do |example|
repo do
`git config --local core.hooksPath /etc/hooks`
example.run
end
end
it 'returns the absolute path' do
expect(subject).to eq File.absolute_path('/etc/hooks')
end
end
context 'when explicitly set to a relative path' do
around do |example|
repo do
`git config --local core.hooksPath my-hooks`
example.run
end
end
it 'returns the absolute path to the directory relative to the repo root' do
expect(subject).to eq File.expand_path('my-hooks')
end
end
end
end