Sha256: 7f9748b725140821751b559bc1bc42a4f55e6dfb5a05e7bc1f471b11148255fd

Contents?: true

Size: 1012 Bytes

Versions: 4

Compression:

Stored size: 1012 Bytes

Contents

require 'spec_helper'
require 'reek/core/module_context'
require 'reek/smells/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)      { Reek::Core::ModuleContext.new(nil, src.to_reek_source.syntax_tree) }

    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

4 entries across 4 versions & 1 rubygems

Version Path
reek-2.0.4 spec/reek/smells/prima_donna_method_spec.rb
reek-2.0.3 spec/reek/smells/prima_donna_method_spec.rb
reek-2.0.2 spec/reek/smells/prima_donna_method_spec.rb
reek-2.0.1 spec/reek/smells/prima_donna_method_spec.rb