Sha256: 894d865f5c95cecc418edf99f49381388f55f56e45e90cabbed97139e9818ff4

Contents?: true

Size: 1.27 KB

Versions: 28

Compression:

Stored size: 1.27 KB

Contents

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

RSpec.describe Reek::SmellDetectors::LongYieldList do
  it 'reports the right values' do
    src = <<-EOS
      class Alfa
        def bravo(charlie, delta, echo, foxtrot)
          yield charlie, delta, echo, foxtrot
        end
      end
    EOS

    expect(src).to reek_of(:LongYieldList,
                           lines:   [3],
                           context: 'Alfa#bravo',
                           message: 'yields 4 parameters',
                           source:  'string',
                           count:   4)
  end

  it 'does count all occurences' do
    src = <<-EOS
      class Alfa
        def bravo(charlie, delta, echo, foxtrot)
          yield charlie, delta, echo, foxtrot
        end

        def golf(hotel, india, juliett, kilo)
          yield hotel, india, juliett, kilo
        end
      end
    EOS

    expect(src).
      to reek_of(:LongYieldList, lines: [3], context: 'Alfa#bravo').
      and reek_of(:LongYieldList, lines: [7], context: 'Alfa#golf')
  end

  it 'does not report yield with 3 parameters' do
    src = <<-EOS
      def alfa(bravo, charlie, delta)
        yield bravo, charlie, delta
      end
    EOS

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

Version data entries

28 entries across 26 versions & 2 rubygems

Version Path
reek-5.3.1 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-5.3.0 spec/reek/smell_detectors/long_yield_list_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_detectors/long_yield_list_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/long_yield_list_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_detectors/long_yield_list_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/long_yield_list_spec.rb
reek-5.2.0 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-5.1.0 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-5.0.2 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-5.0.1 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-5.0.0 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-4.8.2 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-4.8.1 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-4.8.0 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-4.7.3 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-4.7.2 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-4.7.1 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-4.7.0 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-4.6.2 spec/reek/smell_detectors/long_yield_list_spec.rb
reek-4.6.1 spec/reek/smell_detectors/long_yield_list_spec.rb