spec/reek/configuration/app_configuration_spec.rb in reek-3.7.0 vs spec/reek/configuration/app_configuration_spec.rb in reek-3.7.1
- old
+ new
@@ -89,13 +89,12 @@
end
end
end
describe '#directive_for' do
- let(:source_via) { 'spec/samples/three_clean_files/dummy.rb' }
-
- context 'our source is in a directory for which we have a directive' do
+ context 'multiple directory directives and no default directive present' do
+ let(:source_via) { 'spec/samples/three_clean_files/dummy.rb' }
let(:baz_config) { { Reek::Smells::IrresponsibleModule => { enabled: false } } }
let(:bang_config) { { Reek::Smells::Attribute => { enabled: true } } }
let(:directory_directives) do
{
@@ -108,10 +107,33 @@
configuration = described_class.from_map directory_directives: directory_directives
expect(configuration.directive_for(source_via)).to eq(bang_config)
end
end
- context 'our source is not in a directory for which we have a directive' do
+ context 'directory directive and default directive present' do
+ let(:directory) { 'spec/samples/two_smelly_files/' }
+ let(:directory_config) { { Reek::Smells::TooManyStatements => { max_statements: 8 } } }
+ let(:directory_directives) { { directory => directory_config } }
+ let(:default_directive) do
+ {
+ Reek::Smells::IrresponsibleModule => { enabled: false },
+ Reek::Smells::TooManyStatements => { max_statements: 15 }
+ }
+ end
+ let(:source_via) { "#{directory}/dummy.rb" }
+
+ it 'returns the directory directive with the default directive reverse-merged' do
+ configuration = described_class.from_map directory_directives: directory_directives,
+ default_directive: default_directive
+ actual = configuration.directive_for(source_via)
+ expect(actual[Reek::Smells::IrresponsibleModule]).to be_truthy
+ expect(actual[Reek::Smells::TooManyStatements]).to be_truthy
+ expect(actual[Reek::Smells::TooManyStatements][:max_statements]).to eq(8)
+ end
+ end
+
+ context 'no directory directive but a default directive present' do
+ let(:source_via) { 'spec/samples/three_clean_files/dummy.rb' }
let(:default_directive) { { Reek::Smells::IrresponsibleModule => { enabled: false } } }
let(:attribute_config) { { Reek::Smells::Attribute => { enabled: false } } }
let(:directory_directives) do
{ 'spec/samples/two_smelly_files' => attribute_config }
end