Sha256: d5b924b41e9d305d9c0b82079f97e2ef73ae00519c92cc85ca2239e6f34e344b

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

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

RSpec.describe Reek::Smells::TooManyMethods do
  let(:config) do
    { Reek::Smells::TooManyMethods::MAX_ALLOWED_METHODS_KEY => 3 }
  end

  it 'reports the right values' do
    src = <<-EOS
      class Alfa
        def bravo; end
        def charlie; end
        def delta; end
        def echo; end
      end
    EOS

    expect(src).to reek_of(:TooManyMethods,
                           lines:   [1],
                           context: 'Alfa',
                           message: 'has at least 4 methods',
                           source:  'string',
                           count:   4).with_config(config)
  end

  it 'does not report if we stay below max_methods' do
    src = <<-EOS
      class Alfa
        def bravo; end
        def charlie; end
        def delta; end
      end
    EOS

    expect(src).not_to reek_of(:TooManyMethods).with_config(config)
  end

  it 'stops at a nested module' do
    src = <<-EOS
      class Alfa
        def bravo; end
        def charlie; end

        module Hidden
          def delta; end
          def echo; end
        end
      end
    EOS

    expect(src).not_to reek_of(:TooManyMethods).with_config(config)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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