Sha256: bd93935c4eeb5f28210260586206c3185eb952eb9eba67099762eb0bf9e9501b

Contents?: true

Size: 1.1 KB

Versions: 11

Compression:

Stored size: 1.1 KB

Contents

require_relative '../../spec_helper'
require_relative '../../../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, source: 'source_name') }
    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.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

11 entries across 11 versions & 1 rubygems

Version Path
reek-3.4.0 spec/reek/smells/prima_donna_method_spec.rb
reek-3.3.1 spec/reek/smells/prima_donna_method_spec.rb
reek-3.3.0 spec/reek/smells/prima_donna_method_spec.rb
reek-3.2.1 spec/reek/smells/prima_donna_method_spec.rb
reek-3.2 spec/reek/smells/prima_donna_method_spec.rb
reek-3.1 spec/reek/smells/prima_donna_method_spec.rb
reek-3.0.4 spec/reek/smells/prima_donna_method_spec.rb
reek-3.0.3 spec/reek/smells/prima_donna_method_spec.rb
reek-3.0.2 spec/reek/smells/prima_donna_method_spec.rb
reek-3.0.1 spec/reek/smells/prima_donna_method_spec.rb
reek-3.0.0 spec/reek/smells/prima_donna_method_spec.rb