Sha256: 8b8d94735c34e8e2161da85993e9561527aaf3862e904c32e387ce443bd70ae3

Contents?: true

Size: 1.26 KB

Versions: 9

Compression:

Stored size: 1.26 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 = <<-RUBY
      class Alfa
        def bravo; end
        def charlie; end
        def delta; end
        def echo; end
      end
    RUBY

    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 = <<-RUBY
      class Alfa
        def bravo; end
        def charlie; end
        def delta; end
      end
    RUBY

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

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

        module Hidden
          def delta; end
          def echo; end
        end
      end
    RUBY

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
reek-6.0.3 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-6.0.2 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-6.0.1 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-6.0.0 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-5.6.0 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-5.5.0 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-5.4.1 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-5.4.0 spec/reek/smell_detectors/too_many_methods_spec.rb
reek-5.3.2 spec/reek/smell_detectors/too_many_methods_spec.rb