Sha256: 336770b1d05e81d54d040c7bb50c1e4b6489e3470cf40601dc95e8ddf1ec522d

Contents?: true

Size: 1.33 KB

Versions: 14

Compression:

Stored size: 1.33 KB

Contents

require_relative '../../spec_helper'
require_lib 'reek/smells/smell_detector'

RSpec.describe Reek::Smells::SmellDetector do
  describe '.todo_configuration_for' do
    it 'returns exclusion configuration for the given smells' do
      detector = described_class.new
      smell = create(:smell_warning, smell_detector: detector, context: 'Foo#bar')
      result = described_class.todo_configuration_for([smell])
      expect(result).to eq('SmellDetector' => { 'exclude' => ['Foo#bar'] })
    end

    it 'merges identical contexts' do
      detector = described_class.new
      smell = create(:smell_warning, smell_detector: detector, context: 'Foo#bar')
      result = described_class.todo_configuration_for([smell, smell])
      expect(result).to eq('SmellDetector' => { 'exclude' => ['Foo#bar'] })
    end

    context 'with default exclusions present' do
      let(:subclass) { Reek::Smells::TooManyStatements }

      before do
        expect(subclass.default_config['exclude']).to eq ['initialize']
      end

      it 'includes default exclusions' do
        detector = subclass.new
        smell = create(:smell_warning, smell_detector: detector, context: 'Foo#bar')
        result = subclass.todo_configuration_for([smell])

        expect(result).to eq('TooManyStatements' => { 'exclude' => ['initialize', 'Foo#bar'] })
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
reek-4.4.1 spec/reek/smells/smell_detector_spec.rb
reek-4.4.0 spec/reek/smells/smell_detector_spec.rb
reek-4.3.0 spec/reek/smells/smell_detector_spec.rb
reek-4.2.5 spec/reek/smells/smell_detector_spec.rb
reek-4.2.4 spec/reek/smells/smell_detector_spec.rb
reek-4.2.3 spec/reek/smells/smell_detector_spec.rb
reek-4.2.2 spec/reek/smells/smell_detector_spec.rb
reek-4.2.1 spec/reek/smells/smell_detector_spec.rb
reek-4.2.0 spec/reek/smells/smell_detector_spec.rb
reek-4.1.1 spec/reek/smells/smell_detector_spec.rb
reek-4.1.0 spec/reek/smells/smell_detector_spec.rb
reek-4.0.5 spec/reek/smells/smell_detector_spec.rb
reek-4.0.4 spec/reek/smells/smell_detector_spec.rb
reek-4.0.3 spec/reek/smells/smell_detector_spec.rb