Sha256: b592d9f508dab39a3e52a501f7406a61255283760f88f56ddf5fe914ee93cfbe

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 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
    'class C; def m; end; def m!; end; end'.should_not smell_of(PrimaDonnaMethod)
  end

  it 'should report PrimaDonnaMethod when only bang method exists' do
    'class C; def m!; end; end'.should 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]

      warning.smell['class'].should    == 'PrimaDonnaMethod'
      warning.smell['subclass'].should == 'PrimaDonnaMethod'
      warning.lines.should             == [1]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reek-1.3.8 spec/reek/smells/prima_donna_method_spec.rb
reek-1.3.7 spec/reek/smells/prima_donna_method_spec.rb
reek-1.3.6 spec/reek/smells/prima_donna_method_spec.rb