Sha256: a43b72780cce72bd7082f915e7fddef289293b888e49f2535c07be4302c3ef96

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require_relative '../../spec_helper'
require_relative '../../../lib/reek/core/smell_configuration'

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
      enabled_key = Reek::Core::SmellConfiguration::ENABLED_KEY
      @detector.configure_with(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

1 entries across 1 versions & 1 rubygems

Version Path
reek-2.1.0 spec/reek/smells/smell_detector_shared.rb