Sha256: a73524ed4acd12a840411f5eefccca533d945fc7f5b07198be7d30e8f6bd34a2

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require_relative '../../spec_helper'
require_relative '../../../lib/reek/core/module_context'
require_relative 'smell_detector_shared'

describe Reek::Smells::PrimaDonnaMethod do
  it 'should report nothing when method and bang counterpart exist' do
    expect('class C; def m; end; def m!; end; end').not_to reek_of(:PrimaDonnaMethod)
  end

  it 'should report PrimaDonnaMethod when only bang method exists' do
    expect('class C; def m!; end; end').to reek_of(:PrimaDonnaMethod)
  end

  describe 'the right smell' do
    let(:detector) { build(:smell_detector, smell_type: :PrimaDonnaMethod, source: 'source_name') }
    let(:src)      { 'class C; def m!; end; end' }
    let(:ctx)      do
      Reek::Core::ModuleContext.new(nil,
                                    Reek::Source::SourceCode.from(src).syntax_tree)
    end

    it 'should be reported' do
      smells = detector.examine_context(ctx)
      warning = smells[0]

      expect(warning.smell_category).to eq('PrimaDonnaMethod')
      expect(warning.smell_type).to eq('PrimaDonnaMethod')
      expect(warning.lines).to eq([1])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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