Sha256: 4b1716225f686dda1bcdc63f0a79c4e2fea75f1aba15971478af3739adca1f8a

Contents?: true

Size: 940 Bytes

Versions: 2

Compression:

Stored size: 940 Bytes

Contents

require 'spec_helper'

require 'reek/smells/smell_detector_shared'

include Reek
include Reek::Smells

describe 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 smell_of(PrimaDonnaMethod)
  end

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

  describe 'the right smell' do
    let(:detector) { PrimaDonnaMethod.new('dummy_source') }
    let(:src)      { 'class C; def m!; end; end' }
    let(:ctx)      { CodeContext.new(nil, src.to_reek_source.syntax_tree) }

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

      expect(warning.smell_class).to eq('PrimaDonnaMethod')
      expect(warning.subclass).to eq('PrimaDonnaMethod')
      expect(warning.lines).to eq([1])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reek-1.5.1 spec/reek/smells/prima_donna_method_spec.rb
reek-1.5.0 spec/reek/smells/prima_donna_method_spec.rb