@@ -104,8 +104,12 @@ def run
104104 context 'given a project that does not use a Gemfile' do
105105 let ( :hook ) { normalize_indent ( <<-RUBY ) }
106106 module Overcommit::Hook::PreCommit
107- class NoBundlerHook < Base
107+ class NoInvalidGemfileHook < Base
108108 def run
109+ if (gemfile = ENV["BUNDLE_GEMFILE"])
110+ raise unless File.exist?(gemfile)
111+ end
112+
109113 :pass
110114 end
111115 end
@@ -122,7 +126,7 @@ def run
122126 PreCommit:
123127 ALL:
124128 enabled: false
125- NoBundlerHook :
129+ NoInvalidGemfileHook :
126130 enabled: true
127131 requires_files: false
128132 YAML
@@ -133,24 +137,16 @@ def run
133137
134138 `overcommit --install > #{ File ::NULL } `
135139 FileUtils . mkdir_p ( File . join ( '.git-hooks' , 'pre_commit' ) )
136- echo ( hook , File . join ( '.git-hooks' , 'pre_commit' , 'no_bundler_hook .rb' ) )
140+ echo ( hook , File . join ( '.git-hooks' , 'pre_commit' , 'no_invalid_gemfile_hook .rb' ) )
137141
138- Bundler . with_unbundled_env do
139- Overcommit ::Utils . with_environment 'OVERCOMMIT_NO_VERIFY' => '1' do
140- example . run
141- end
142+ Overcommit ::Utils . with_environment 'OVERCOMMIT_NO_VERIFY' => '1' do
143+ example . run
142144 end
143145 end
144146 end
145147
146148 subject { shell ( %w[ git commit --allow-empty -m Test ] ) }
147149
148- context 'when configuration does not specify a gemfile' do
149- it 'runs the hook successfully' do
150- subject . status . should == 0
151- end
152- end
153-
154150 context 'when configuration explicitly sets the gemfile to false' do
155151 let ( :config ) { "gemfile: false\n " + super ( ) }
156152
0 commit comments