Skip to content

Commit e9e0902

Browse files
jawshooahsds
authored andcommitted
Add touch helper for specs
1 parent 8498b8a commit e9e0902

14 files changed

+47
-43
lines changed

spec/integration/disable_overcommit_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
repo do
88
`overcommit --install > #{File::NULL}`
99
Overcommit::Utils.with_environment('OVERCOMMIT_DISABLE' => overcommit_disable) do
10-
FileUtils.touch 'blah'
10+
touch 'blah'
1111
`git add blah`
1212
example.run
1313
end

spec/integration/gemfile_option_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def run
5656
Bundler.with_clean_env do
5757
FileUtils.mkdir_p(File.join(fake_gem_path, 'lib'))
5858
echo(gemspec, File.join(fake_gem_path, 'my_fake_gem.gemspec'))
59-
FileUtils.touch(File.join(fake_gem_path, 'lib', 'my_fake_gem.rb'))
59+
touch(File.join(fake_gem_path, 'lib', 'my_fake_gem.rb'))
6060

6161
echo(gemfile, '.overcommit_gems.rb')
6262
`bundle install --gemfile=.overcommit_gems.rb`

spec/overcommit/git_repo_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
let(:file) { "#{dir}/file" }
128128

129129
before do
130-
FileUtils.touch(file)
130+
touch(file)
131131
`git add "#{file}"`
132132
`git commit -m "Add file"`
133133
end

spec/overcommit/hook/pre_commit/berksfile_check_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
context 'when Berksfile.lock is ignored' do
99
around do |example|
1010
repo do
11-
FileUtils.touch 'Berksfile.lock'
11+
touch 'Berksfile.lock'
1212
echo('Berksfile.lock', '.gitignore')
1313
`git add .gitignore`
1414
`git commit -m "Ignore Berksfile.lock"`

spec/overcommit/hook/pre_commit/bundle_check_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
context 'when Gemfile.lock is ignored' do
99
around do |example|
1010
repo do
11-
FileUtils.touch 'Gemfile.lock'
11+
touch 'Gemfile.lock'
1212
echo('Gemfile.lock', '.gitignore')
1313
`git add .gitignore`
1414
`git commit -m "Ignore Gemfile.lock"`

spec/overcommit/hook/pre_commit/json_syntax_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
around do |example|
1616
repo do
17-
FileUtils.touch staged_file
17+
touch staged_file
1818
`git add #{staged_file}`
1919
example.run
2020
end

spec/overcommit/hook_context/post_checkout_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
it 'does not include submodules' do
6060
submodule = repo do
61-
FileUtils.touch 'foo'
61+
touch 'foo'
6262
`git add foo`
6363
`git commit -m "Initial commit"`
6464
end
@@ -87,7 +87,7 @@
8787
around do |example|
8888
repo do
8989
`git commit --allow-empty -m "Initial commit"`
90-
FileUtils.touch('some-file')
90+
touch('some-file')
9191
`git add some-file`
9292
`git commit -m "Add file"`
9393
example.run
@@ -100,7 +100,7 @@
100100
context 'when files were modified' do
101101
around do |example|
102102
repo do
103-
FileUtils.touch('some-file')
103+
touch('some-file')
104104
`git add some-file`
105105
`git commit -m "Initial commit"`
106106
echo('Hello', 'some-file')
@@ -116,7 +116,7 @@
116116
context 'when files were deleted' do
117117
around do |example|
118118
repo do
119-
FileUtils.touch('some-file')
119+
touch('some-file')
120120
`git add some-file`
121121
`git commit -m "Initial commit"`
122122
`git rm some-file`
@@ -131,7 +131,7 @@
131131
context 'when files were renamed' do
132132
around do |example|
133133
repo do
134-
FileUtils.touch 'some-file'
134+
touch 'some-file'
135135
`git add some-file`
136136
`git commit -m "Add file"`
137137
`git mv some-file renamed-file`

spec/overcommit/hook_context/post_commit_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
it 'does not include submodules' do
1414
submodule = repo do
15-
FileUtils.touch 'foo'
15+
touch 'foo'
1616
`git add foo`
1717
`git commit -m "Initial commit"`
1818
end
@@ -38,7 +38,7 @@
3838
context 'when files were added' do
3939
around do |example|
4040
repo do
41-
FileUtils.touch('some-file')
41+
touch('some-file')
4242
`git add some-file`
4343
`git commit -m "Initial commit"`
4444
example.run
@@ -51,7 +51,7 @@
5151
context 'when files were modified' do
5252
around do |example|
5353
repo do
54-
FileUtils.touch('some-file')
54+
touch('some-file')
5555
`git add some-file`
5656
`git commit -m "Initial commit"`
5757
echo('Hello', 'some-file')
@@ -67,7 +67,7 @@
6767
context 'when files were deleted' do
6868
around do |example|
6969
repo do
70-
FileUtils.touch('some-file')
70+
touch('some-file')
7171
`git add some-file`
7272
`git commit -m "Initial commit"`
7373
`git rm some-file`

spec/overcommit/hook_context/post_merge_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484

8585
it 'does not include submodules' do
8686
submodule = repo do
87-
FileUtils.touch 'foo'
87+
touch 'foo'
8888
`git add foo`
8989
`git commit -m "Initial commit"`
9090
end
@@ -120,7 +120,7 @@
120120
repo do
121121
`git commit --allow-empty -m "Initial commit"`
122122
`git checkout -b child > #{File::NULL} 2>&1`
123-
FileUtils.touch('some-file')
123+
touch('some-file')
124124
`git add some-file`
125125
`git commit -m "Branch commit"`
126126
`git checkout master > #{File::NULL} 2>&1`
@@ -135,7 +135,7 @@
135135
context 'when files were modified' do
136136
around do |example|
137137
repo do
138-
FileUtils.touch('some-file')
138+
touch('some-file')
139139
`git add some-file`
140140
`git commit -m "Initial commit"`
141141
`git checkout -b child > #{File::NULL} 2>&1`
@@ -154,7 +154,7 @@
154154
context 'when files were deleted' do
155155
around do |example|
156156
repo do
157-
FileUtils.touch('some-file')
157+
touch('some-file')
158158
`git add some-file`
159159
`git commit -m "Initial commit"`
160160
`git checkout -b child > #{File::NULL} 2>&1`
@@ -176,7 +176,7 @@
176176
repo do
177177
`git commit --allow-empty -m "Initial commit"`
178178
`git checkout -b child > #{File::NULL} 2>&1`
179-
FileUtils.touch('some-file')
179+
touch('some-file')
180180
`git add some-file`
181181
`git commit -m "Branch commit"`
182182
`git checkout master > #{File::NULL} 2>&1`

spec/overcommit/hook_context/post_rewrite_spec.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393

9494
it 'does not include submodules' do
9595
submodule = repo do
96-
FileUtils.touch 'foo'
96+
touch 'foo'
9797
`git add foo`
9898
`git commit -m "Initial commit"`
9999
end
@@ -122,7 +122,7 @@
122122
around do |example|
123123
repo do
124124
`git commit --allow-empty -m "Initial commit"`
125-
FileUtils.touch('some-file')
125+
touch('some-file')
126126
`git add some-file`
127127
`git commit --amend -m "Add file"`
128128
example.run
@@ -135,7 +135,7 @@
135135
context 'when files were modified' do
136136
around do |example|
137137
repo do
138-
FileUtils.touch('some-file')
138+
touch('some-file')
139139
`git add some-file`
140140
`git commit -m "Initial commit"`
141141
echo('Hello', 'some-file')
@@ -151,7 +151,7 @@
151151
context 'when files were deleted' do
152152
around do |example|
153153
repo do
154-
FileUtils.touch('some-file')
154+
touch('some-file')
155155
`git add some-file`
156156
`git commit -m "Initial commit"`
157157
`git rm some-file`
@@ -166,7 +166,7 @@
166166
context 'when files were renamed' do
167167
around do |example|
168168
repo do
169-
FileUtils.touch 'some-file'
169+
touch 'some-file'
170170
`git add some-file`
171171
`git commit -m "Add file"`
172172
`git mv some-file renamed-file`
@@ -187,7 +187,7 @@
187187
`git commit -m "Add file"`
188188
`git rm some-symlink`
189189
FileUtils.mkdir 'some-symlink'
190-
FileUtils.touch File.join('some-symlink', 'another-file')
190+
touch File.join('some-symlink', 'another-file')
191191
`git add some-symlink`
192192
`git commit --amend -m "Change symlink to directory"`
193193
example.run
@@ -203,7 +203,7 @@
203203
around do |example|
204204
repo do
205205
FileUtils.mkdir 'some-directory'
206-
FileUtils.touch File.join('some-directory', 'some-file')
206+
touch File.join('some-directory', 'some-file')
207207
symlink('some-directory', 'some-symlink')
208208
`git add some-symlink some-directory`
209209
`git commit -m "Add file"`

spec/overcommit/hook_context/pre_commit_spec.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
around do |example|
155155
repo do
156156
`git commit --allow-empty -m "Initial commit"`
157-
FileUtils.touch 'some-file'
157+
touch 'some-file'
158158
`git add some-file`
159159
`git commit -m "Add file"`
160160
`git mv some-file renamed-file`
@@ -410,7 +410,7 @@
410410

411411
it 'does not include submodules' do
412412
submodule = repo do
413-
FileUtils.touch 'foo'
413+
touch 'foo'
414414
`git add foo`
415415
`git commit -m "Initial commit"`
416416
end
@@ -434,7 +434,7 @@
434434
context 'when files were added' do
435435
around do |example|
436436
repo do
437-
FileUtils.touch('some-file')
437+
touch('some-file')
438438
`git add some-file`
439439
example.run
440440
end
@@ -446,7 +446,7 @@
446446
context 'when files were modified' do
447447
around do |example|
448448
repo do
449-
FileUtils.touch('some-file')
449+
touch('some-file')
450450
`git add some-file`
451451
`git commit -m "Initial commit"`
452452
echo('Hello', 'some-file')
@@ -461,7 +461,7 @@
461461
context 'when files were deleted' do
462462
around do |example|
463463
repo do
464-
FileUtils.touch('some-file')
464+
touch('some-file')
465465
`git add some-file`
466466
`git commit -m "Initial commit"`
467467
`git rm some-file`
@@ -475,10 +475,10 @@
475475
context 'when amending last commit' do
476476
around do |example|
477477
repo do
478-
FileUtils.touch('some-file')
478+
touch('some-file')
479479
`git add some-file`
480480
`git commit -m "Initial commit"`
481-
FileUtils.touch('other-file')
481+
touch('other-file')
482482
`git add other-file`
483483
example.run
484484
end
@@ -495,7 +495,7 @@
495495
around do |example|
496496
repo do
497497
`git commit --allow-empty -m "Initial commit"`
498-
FileUtils.touch 'some-file'
498+
touch 'some-file'
499499
`git add some-file`
500500
`git commit -m "Add file"`
501501
`git mv some-file renamed-file`
@@ -522,7 +522,7 @@
522522
`git commit -m "Add file"`
523523
`git rm some-symlink`
524524
FileUtils.mkdir 'some-symlink'
525-
FileUtils.touch File.join('some-symlink', 'another-file')
525+
touch File.join('some-symlink', 'another-file')
526526
`git add some-symlink`
527527
example.run
528528
end
@@ -542,7 +542,7 @@
542542
repo do
543543
`git commit --allow-empty -m "Initial commit"`
544544
FileUtils.mkdir 'some-directory'
545-
FileUtils.touch File.join('some-directory', 'some-file')
545+
touch File.join('some-directory', 'some-file')
546546
symlink('some-directory', 'some-symlink')
547547
`git add some-symlink some-directory`
548548
`git commit -m "Add file"`

spec/overcommit/hook_context/run_all_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
context 'when repo contains files' do
2424
around do |example|
2525
repo do
26-
FileUtils.touch('some-file')
26+
touch('some-file')
2727
`git add some-file`
28-
FileUtils.touch('some-other-file')
28+
touch('some-other-file')
2929
`git add some-other-file`
3030
`git commit -m "Add files"`
3131
example.run
@@ -38,7 +38,7 @@
3838
context 'when repo contains submodules' do
3939
around do |example|
4040
submodule = repo do
41-
FileUtils.touch 'foo'
41+
touch 'foo'
4242
`git add foo`
4343
`git commit -m "Initial commit"`
4444
end

spec/overcommit/installer_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
before do
7777
FileUtils.mkdir_p(hooks_dir)
7878
Dir.chdir(hooks_dir) do
79-
old_hooks.each { |hook_type| FileUtils.touch(hook_type) }
79+
old_hooks.each { |hook_type| touch(hook_type) }
8080
end
8181
end
8282

@@ -184,7 +184,7 @@
184184
before do
185185
FileUtils.mkdir_p(old_hooks_dir)
186186
Dir.chdir(old_hooks_dir) do
187-
old_hooks.each { |hook_type| FileUtils.touch(hook_type) }
187+
old_hooks.each { |hook_type| touch(hook_type) }
188188
end
189189
end
190190

@@ -201,7 +201,7 @@
201201
before do
202202
FileUtils.mkdir_p(hooks_dir)
203203
Dir.chdir(hooks_dir) do
204-
old_hooks.each { |hook_type| FileUtils.touch(hook_type) }
204+
old_hooks.each { |hook_type| touch(hook_type) }
205205
end
206206
end
207207

spec/support/shell_helpers.rb

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ def symlink(source, dest)
1111
Overcommit::Utils::FileUtils.symlink(source, dest)
1212
end
1313

14+
def touch(file)
15+
FileUtils.touch(file)
16+
end
17+
1418
# Wait until the specified condition is true or the given timeout has elapsed,
1519
# whichever comes first.
1620
#

0 commit comments

Comments
 (0)