Sha256: f410da303a5ff7c08603c09fd465c0959cbcc071476237f6311c4a9d4a05db8b

Contents?: true

Size: 1.25 KB

Versions: 28

Compression:

Stored size: 1.25 KB

Contents

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

RSpec.describe Reek::SmellDetectors::TooManyMethods do
  let(:config) do
    { Reek::SmellDetectors::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

28 entries across 26 versions & 2 rubygems

Version Path
reek-5.3.1 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-5.3.0 spec/reek/smell_detectors/too_many_methods_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_detectors/too_many_methods_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_detectors/too_many_methods_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_detectors/too_many_methods_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_detectors/too_many_methods_spec.rb
reek-5.2.0 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-5.1.0 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-5.0.2 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-5.0.1 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-5.0.0 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-4.8.2 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-4.8.1 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-4.8.0 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-4.7.3 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-4.7.2 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-4.7.1 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-4.7.0 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-4.6.2 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-4.6.1 spec/reek/smell_detectors/too_many_methods_spec.rb