spec/reek/configuration/app_configuration_spec.rb in reek-5.2.0 vs spec/reek/configuration/app_configuration_spec.rb in reek-5.3.0

- old
+ new

@@ -6,11 +6,11 @@ require_lib 'reek/configuration/excluded_paths' RSpec.describe Reek::Configuration::AppConfiguration do describe 'factory methods' do around do |example| - Dir.mktmpdir('/tmp') do |tmp| + Dir.mktmpdir do |tmp| Dir.chdir(tmp) do example.run end end end @@ -30,34 +30,33 @@ let(:expected_default_directive) do { Reek::SmellDetectors::IrresponsibleModule => { 'enabled' => false } } end let(:expected_directory_directives) do - { Pathname('directory_with_some_ruby_files') => - { Reek::SmellDetectors::UtilityFunction => { 'enabled' => false } } } + { Pathname('directory_with_some_ruby_files') => { + Reek::SmellDetectors::UtilityFunction => { 'enabled' => false } + } } end describe '#from_path' do let(:configuration_path) { 'config.reek' } let(:configuration) do - <<-EOF.strip_heredoc - --- - detectors: - IrresponsibleModule: - enabled: false - - directories: - "directory_with_some_ruby_files": - UtilityFunction: + <<~YAML + --- + detectors: + IrresponsibleModule: enabled: false - - exclude_paths: - - "exclude_me.rb" - - "exclude_me_too.rb" - - "directory_with_trailing_slash/" - - "directory_without_trailing_slash" - EOF + directories: + "directory_with_some_ruby_files": + UtilityFunction: + enabled: false + exclude_paths: + - "exclude_me.rb" + - "exclude_me_too.rb" + - "directory_with_trailing_slash/" + - "directory_without_trailing_slash" + YAML end before do File.write configuration_path, configuration FileUtils.touch expected_exclude_file_names @@ -78,18 +77,21 @@ FileUtils.touch expected_exclude_file_names FileUtils.mkdir expected_exclude_directories end let(:default_directive_value) do - { Reek::DETECTORS_KEY => - { 'IrresponsibleModule' => { 'enabled' => false } } } + { Reek::DETECTORS_KEY => { + 'IrresponsibleModule' => { 'enabled' => false } + } } end let(:directory_directives_value) do - { Reek::DIRECTORIES_KEY => - { 'directory_with_some_ruby_files' => - { 'UtilityFunction' => { 'enabled' => false } } } } + { Reek::DIRECTORIES_KEY => { + 'directory_with_some_ruby_files' => { + 'UtilityFunction' => { 'enabled' => false } + } + } } end let(:exclude_paths_value) do { Reek::EXCLUDE_PATHS_KEY => (expected_exclude_file_names + expected_exclude_directories) } end @@ -126,15 +128,16 @@ let(:baz_config) { { IrresponsibleModule: { enabled: false } } } let(:bang_config) { { Attribute: { enabled: true } } } let(:expected_result) { { Reek::SmellDetectors::Attribute => { enabled: true } } } let(:directory_directives) do - { Reek::DIRECTORIES_KEY => - { - 'samples/some_files' => bang_config, + { + Reek::DIRECTORIES_KEY => { + 'samples/some_files' => bang_config, 'samples/other_files' => baz_config - } } + } + } end it 'returns the corresponding directive' do configuration = described_class.from_hash directory_directives expect(configuration.directive_for(source_via)).to eq expected_result @@ -145,15 +148,16 @@ let(:directory) { 'spec/samples/two_smelly_files/' } let(:source_via) { "#{directory}/dummy.rb" } let(:configuration_as_hash) do { - Reek::DIRECTORIES_KEY => - { directory => { TooManyStatements: { max_statements: 8 } } }, - Reek::DETECTORS_KEY => { + Reek::DIRECTORIES_KEY => { + directory => { TooManyStatements: { max_statements: 8 } } + }, + Reek::DETECTORS_KEY => { IrresponsibleModule: { enabled: false }, - TooManyStatements: { max_statements: 15 } + TooManyStatements: { max_statements: 15 } } } end it 'returns the directory directive with the default directive reverse-merged' do @@ -169,14 +173,15 @@ context 'with a path not covered by a directory directive but a default directive present' do let(:source_via) { 'samples/some_files/dummy.rb' } let(:configuration_as_hash) do { - Reek::DETECTORS_KEY => { + Reek::DETECTORS_KEY => { IrresponsibleModule: { enabled: false } }, - Reek::DIRECTORIES_KEY => - { 'samples/other_files' => { Attribute: { enabled: false } } } + Reek::DIRECTORIES_KEY => { + 'samples/other_files' => { Attribute: { enabled: false } } + } } end let(:expected_result) { { Reek::SmellDetectors::IrresponsibleModule => { enabled: false } } }