Sha256: 061d6258bb52be061989d0e2a645cccc78475bbbef949eaa348084d5f633fc71

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

require_relative '../../spec_helper'
require_lib 'reek/context/module_context'
require_relative 'smell_detector_shared'

RSpec.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) }
    let(:src)      { 'class C; def m!; end; end' }
    let(:ctx)      do
      Reek::Context::ModuleContext.new(nil,
                                       Reek::Source::SourceCode.from(src).syntax_tree)
    end

    it 'should be reported' do
      smells = detector.inspect(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

13 entries across 13 versions & 1 rubygems

Version Path
reek-3.11 spec/reek/smells/prima_donna_method_spec.rb
reek-3.10.2 spec/reek/smells/prima_donna_method_spec.rb
reek-3.10.1 spec/reek/smells/prima_donna_method_spec.rb
reek-3.10.0 spec/reek/smells/prima_donna_method_spec.rb
reek-3.9.1 spec/reek/smells/prima_donna_method_spec.rb
reek-3.9.0 spec/reek/smells/prima_donna_method_spec.rb
reek-3.8.3 spec/reek/smells/prima_donna_method_spec.rb
reek-3.8.2 spec/reek/smells/prima_donna_method_spec.rb
reek-3.8.1 spec/reek/smells/prima_donna_method_spec.rb
reek-3.8.0 spec/reek/smells/prima_donna_method_spec.rb
reek-3.7.1 spec/reek/smells/prima_donna_method_spec.rb
reek-3.7.0 spec/reek/smells/prima_donna_method_spec.rb
reek-3.6.1 spec/reek/smells/prima_donna_method_spec.rb