|
173 | 173 | end
|
174 | 174 | end
|
175 | 175 | end
|
| 176 | + |
| 177 | + describe '#apply_environment!' do |
| 178 | + let(:hash) { {} } |
| 179 | + let(:config) { described_class.new(hash) } |
| 180 | + let!(:old_config) { described_class.new(hash.dup) } |
| 181 | + subject { config } |
| 182 | + |
| 183 | + before do |
| 184 | + config.apply_environment!('pre-commit', env) |
| 185 | + end |
| 186 | + |
| 187 | + context 'when no hooks are requested to be skipped' do |
| 188 | + let(:env) { {} } |
| 189 | + |
| 190 | + it 'does nothing to the configuration' do |
| 191 | + subject.should == old_config |
| 192 | + end |
| 193 | + end |
| 194 | + |
| 195 | + context 'when a non-existent hook is requested to be skipped' do |
| 196 | + let(:env) { { 'SKIP' => 'SomeMadeUpHook' } } |
| 197 | + |
| 198 | + it 'does nothing to the configuration' do |
| 199 | + subject.should == old_config |
| 200 | + end |
| 201 | + end |
| 202 | + |
| 203 | + context 'when an existing hook is requested to be skipped' do |
| 204 | + let(:env) { { 'SKIP' => 'AuthorName' } } |
| 205 | + |
| 206 | + it 'sets the skip option of the hook to true' do |
| 207 | + subject.for_hook('AuthorName', 'pre_commit')['skip'].should be_true |
| 208 | + end |
| 209 | + |
| 210 | + context 'and the hook is spelt with underscores' do |
| 211 | + let(:env) { { 'SKIP' => 'author_name' } } |
| 212 | + |
| 213 | + it 'sets the skip option of the hook to true' do |
| 214 | + subject.for_hook('AuthorName', 'pre_commit')['skip'].should be_true |
| 215 | + end |
| 216 | + end |
| 217 | + |
| 218 | + context 'and the hook is spelt with hyphens' do |
| 219 | + let(:env) { { 'SKIP' => 'author-name' } } |
| 220 | + |
| 221 | + it 'sets the skip option of the hook to true' do |
| 222 | + subject.for_hook('AuthorName', 'pre_commit')['skip'].should be_true |
| 223 | + end |
| 224 | + end |
| 225 | + end |
| 226 | + |
| 227 | + context 'when the word "all" is included in the skip list' do |
| 228 | + let(:env) { { 'SKIP' => 'all' } } |
| 229 | + |
| 230 | + it 'sets the skip option of the ALL section to true' do |
| 231 | + subject.for_hook('ALL', 'pre_commit')['skip'].should be_true |
| 232 | + end |
| 233 | + |
| 234 | + context 'and "all" is capitalized' do |
| 235 | + let(:env) { { 'SKIP' => 'ALL' } } |
| 236 | + |
| 237 | + it 'sets the skip option of the special ALL config to true' do |
| 238 | + subject.for_hook('ALL', 'pre_commit')['skip'].should be_true |
| 239 | + end |
| 240 | + end |
| 241 | + end |
| 242 | + end |
176 | 243 | end
|
0 commit comments