Sha256: 7f78e867bb76b4b733392a1fb0fcff171bb58049b3f18e531ca3330ba1184f40

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'
require 'reek/core/smell_configuration'

include Reek::Core

shared_examples_for 'SmellDetector' do
  context 'exception matching follows the context' do
    before :each do
      @ctx = double('context')
      allow(@ctx).to receive(:config_for).and_return({})
    end
    it 'when false' do
      expect(@ctx).to receive(:matches?).at_least(:once).and_return(false)
      expect(@detector.exception?(@ctx)).to eq(false)
    end

    it 'when true' do
      expect(@ctx).to receive(:matches?).at_least(:once).and_return(true)
      expect(@detector.exception?(@ctx)).to eq(true)
    end
  end

  context 'configuration' do
    it 'becomes disabled when disabled' do
      @detector.configure_with(SmellConfiguration::ENABLED_KEY => false)
      expect(@detector).not_to be_enabled
    end
  end
end

shared_examples_for 'common fields set correctly' do
  it 'reports the source' do
    expect(@warning.source).to eq(@source_name)
  end
  it 'reports the smell class' do
    expect(@warning.smell_category).to eq(@detector.smell_category)
  end
  it 'reports the smell sub class' do
    expect(@warning.smell_type).to eq(@detector.smell_type)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
reek-2.0.1 spec/reek/smells/smell_detector_shared.rb
reek-2.0.0 spec/reek/smells/smell_detector_shared.rb
reek-1.6.6 spec/reek/smells/smell_detector_shared.rb
reek-1.6.5 spec/reek/smells/smell_detector_shared.rb
reek-1.6.4 spec/reek/smells/smell_detector_shared.rb
reek-1.6.3 spec/reek/smells/smell_detector_shared.rb
reek-1.6.2 spec/reek/smells/smell_detector_shared.rb
reek-1.6.1 spec/reek/smells/smell_detector_shared.rb
reek-1.6.0 spec/reek/smells/smell_detector_shared.rb