|
58 | 58 | end |
59 | 59 | end |
60 | 60 |
|
61 | | - context 'when repo contains a local configuration file' do |
| 61 | + context 'when repo only contains a repo level configuration file' do |
62 | 62 | let(:config_contents) { <<-CFG } |
63 | | - plugin_directory: 'some-directory' |
| 63 | + PreCommit: |
| 64 | + Rubocop: |
| 65 | + enabled: true |
64 | 66 | CFG |
65 | 67 |
|
| 68 | + around do |example| |
| 69 | + repo do |
| 70 | + File.open('.overcommit.yml', 'w') { |f| f.write(config_contents) } |
| 71 | + example.run |
| 72 | + end |
| 73 | + end |
| 74 | + |
| 75 | + it 'includes default settings' do |
| 76 | + subject |
| 77 | + subject.for_hook('CapitalizedSubject', 'CommitMsg').should include('enabled' => true) |
| 78 | + end |
| 79 | + |
| 80 | + it 'includes .overwrite.yml configs' do |
| 81 | + subject |
| 82 | + subject.for_hook('Rubocop', 'PreCommit').should include('enabled' => true) |
| 83 | + end |
| 84 | + end |
| 85 | + |
| 86 | + context 'when repo also contains a local configuration file' do |
66 | 87 | let(:local_config_contents) { <<-CFG } |
67 | 88 | plugin_directory: 'some-different-directory' |
68 | 89 | CFG |
|
75 | 96 | end |
76 | 97 | end |
77 | 98 |
|
78 | | - it 'loads the file' do |
79 | | - Overcommit::ConfigurationLoader.any_instance. |
80 | | - should_receive(:load_file). |
81 | | - with(File.expand_path('.overcommit.yml'), File.expand_path('.local-overcommit.yml')) |
| 99 | + let(:config_contents) { <<-CFG } |
| 100 | + PreCommit: |
| 101 | + ScssLint: |
| 102 | + enabled: true |
| 103 | + CFG |
| 104 | + |
| 105 | + let(:local_config_contents) { <<-CFG } |
| 106 | + PreCommit: |
| 107 | + Rubocop: |
| 108 | + enabled: true |
| 109 | + CFG |
| 110 | + |
| 111 | + it 'includes default settings' do |
82 | 112 | subject |
| 113 | + subject.for_hook('CapitalizedSubject', 'CommitMsg').should include('enabled' => true) |
83 | 114 | end |
84 | 115 |
|
85 | | - it 'merges each loaded file with the default configuration' do |
86 | | - subject.plugin_directory.should == File.expand_path('some-different-directory') |
| 116 | + it 'includes .overwrite.yml configs' do |
| 117 | + subject |
| 118 | + subject.for_hook('ScssLint', 'PreCommit').should include('enabled' => true) |
87 | 119 | end |
88 | 120 |
|
89 | | - context 'and the configuration file contains a hook with no `enabled` option' do |
90 | | - let(:config_contents) { <<-CFG } |
91 | | - PreCommit: |
92 | | - ScssLint: |
93 | | - command: ['bundle', 'exec', 'scss-lint'] |
94 | | - CFG |
95 | | - |
96 | | - it 'displays a warning' do |
97 | | - subject |
98 | | - output.string.should =~ /PreCommit::ScssLint.*not.*enabled/i |
99 | | - end |
| 121 | + it 'includes .local-overwrite.yml configs' do |
| 122 | + subject |
| 123 | + subject.for_hook('Rubocop', 'PreCommit').should include('enabled' => true) |
100 | 124 | end |
101 | 125 | end |
102 | 126 | end |
|
0 commit comments