Sha256: da91c4aee6e35dc3a1c1ebbfa689106fcff83d4e78327afc53c7b5e8a2de4da6

Contents?: true

Size: 1.89 KB

Versions: 27

Compression:

Stored size: 1.89 KB

Contents

require_relative '../spec_helper'
require_lib 'reek/smell_configuration'

RSpec.describe Reek::SmellConfiguration do
  context 'when overriding default configs' do
    let(:base_config) do
      {
        'accept'  => ['_'],
        'enabled' => true,
        'exclude' => [],
        'reject'  => [/^.$/, /[0-9]$/, /[A-Z]/]
      }
    end

    let(:smell_config) { described_class.new(base_config) }

    it { expect(smell_config.merge({})).to eq(base_config) }
    it { expect(smell_config.merge('enabled' => true)).to eq(base_config) }
    it { expect(smell_config.merge('exclude' => [])).to eq(base_config) }
    it { expect(smell_config.merge('accept' => ['_'])).to eq(base_config) }
    it do
      updated = smell_config.merge('reject' => [/^.$/, /[0-9]$/, /[A-Z]/])
      expect(updated).to eq(base_config)
    end
    it do
      updated = smell_config.merge('accept' => ['_'], 'enabled' => true)
      expect(updated).to eq(base_config)
    end

    it 'overrides single values' do
      updated = smell_config.merge('enabled' => false)
      expect(updated).to eq('accept'  => ['_'],
                            'enabled' => false,
                            'exclude' => [],
                            'reject'  => [/^.$/, /[0-9]$/, /[A-Z]/])
    end

    it 'overrides arrays of values' do
      updated = smell_config.merge('reject' => [/^.$/, /[3-9]$/])
      expect(updated).to eq('accept'  => ['_'],
                            'enabled' => true,
                            'exclude' => [],
                            'reject'  => [/^.$/, /[3-9]$/])
    end

    it 'overrides multiple values' do
      updated = smell_config.merge('accept' => [/[A-Z]$/], 'enabled' => false)
      expect(updated).to eq('accept'  => [/[A-Z]$/],
                            'enabled' => false,
                            'exclude' => [],
                            'reject'  => [/^.$/, /[0-9]$/, /[A-Z]/])
    end
  end
end

Version data entries

27 entries across 25 versions & 2 rubygems

Version Path
reek-5.4.0 spec/reek/smell_configuration_spec.rb
reek-5.3.2 spec/reek/smell_configuration_spec.rb
reek-5.3.1 spec/reek/smell_configuration_spec.rb
reek-5.3.0 spec/reek/smell_configuration_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_configuration_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_configuration_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_configuration_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_configuration_spec.rb
reek-5.2.0 spec/reek/smell_configuration_spec.rb
reek-5.1.0 spec/reek/smell_configuration_spec.rb
reek-5.0.2 spec/reek/smell_configuration_spec.rb
reek-5.0.1 spec/reek/smell_configuration_spec.rb
reek-5.0.0 spec/reek/smell_configuration_spec.rb
reek-4.8.2 spec/reek/smell_configuration_spec.rb
reek-4.8.1 spec/reek/smell_configuration_spec.rb
reek-4.8.0 spec/reek/smell_configuration_spec.rb
reek-4.7.3 spec/reek/smell_configuration_spec.rb
reek-4.7.2 spec/reek/smell_configuration_spec.rb
reek-4.7.1 spec/reek/smell_configuration_spec.rb
reek-4.7.0 spec/reek/smell_configuration_spec.rb