Sha256: a118f0d1baab7af1e2bce913af41cd02d362f55fa6b74e323eee359b08e0aa24

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require_relative '../../spec_helper'
require_lib 'reek/smells/prima_donna_method'

RSpec.describe Reek::Smells::PrimaDonnaMethod do
  it 'reports the right values' do
    src = <<-EOS
      class Alfa
        def bravo!
        end
      end
    EOS

    expect(src).to reek_of(:PrimaDonnaMethod,
                           lines:   [1],
                           context: 'Alfa',
                           message: "has prima donna method 'bravo!'",
                           source:  'string',
                           name:    'bravo!')
  end

  it 'does count all occurences' do
    src = <<-EOS
      class Alfa
        def bravo!
        end

        def charlie!
        end
      end
    EOS

    expect(src).
      to reek_of(:PrimaDonnaMethod, lines: [1], name: 'bravo!').
      and reek_of(:PrimaDonnaMethod, lines: [1], name: 'charlie!')
  end

  it 'reports nothing when method and bang counterpart exist' do
    src = <<-EOS
      class Alfa
        def bravo
        end

        def bravo!
        end
      end
    EOS

    expect(src).not_to reek_of(:PrimaDonnaMethod)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reek-4.4.2 spec/reek/smells/prima_donna_method_spec.rb