-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathdefault_configuration_spec.rb
More file actions
40 lines (32 loc) · 1.36 KB
/
Copy pathdefault_configuration_spec.rb
File metadata and controls
40 lines (32 loc) · 1.36 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
# frozen_string_literal: true
require 'spec_helper'
describe 'default configuration' do
default_config =
begin
YAML.load_file(Overcommit::ConfigurationLoader::DEFAULT_CONFIG_PATH, aliases: true).to_hash
rescue ArgumentError
YAML.load_file(Overcommit::ConfigurationLoader::DEFAULT_CONFIG_PATH).to_hash
end
Overcommit::Utils.supported_hook_types.each do |hook_type|
hook_class = Overcommit::Utils.camel_case(hook_type)
Dir[File.join(Overcommit::HOOK_DIRECTORY, hook_type.tr('-', '_'), '*')].
map { |hook_file| Overcommit::Utils.camel_case(File.basename(hook_file, '.rb')) }.
each do |hook|
next if hook == 'Base'
context "for the #{hook} #{hook_type} hook" do
it 'exists in config/default.yml' do
default_config[hook_class][hook].should_not be_nil
end
it 'explicitly sets the enabled option' do
# Use variable names so it reads nicer in the RSpec output
hook_enabled_option_set = !default_config[hook_class][hook]['enabled'].nil?
all_hook_enabled_option_set = !default_config[hook_class]['ALL']['enabled'].nil?
(hook_enabled_option_set || all_hook_enabled_option_set).should == true
end
it 'defines a description' do
default_config[hook_class][hook]['description'].should_not be_nil
end
end
end
end
end