Sha256: 26d7392e13e0512a6b7d7a20b1f54ac34bce85d108965096b84bc63a9af85c6a

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

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

RSpec.describe Reek::Smells::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

1 entries across 1 versions & 1 rubygems

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