Sha256: 17fafdd4616edd35c9acd9de702a5f0f10ed282b20abab0ca3b0b0cfad020276

Contents?: true

Size: 940 Bytes

Versions: 35

Compression:

Stored size: 940 Bytes

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

require 'reek/smells/nested_iterators'

include Reek::Smells

describe NestedIterators do

  it 'should report nested iterators in a method' do
    'def bad(fred) @fred.each {|item| item.each {|ting| ting.ting} } end'.should reek_only_of(:NestedIterators)
  end

  it 'should not report method with successive iterators' do
    'def bad(fred)
      @fred.each {|item| item.each }
      @jim.each {|ting| ting.each }
    end'.should_not reek
  end

  it 'should not report method with chained iterators' do
    'def chained
      @sig.keys.sort_by { |xray| xray.to_s }.each { |min| md5 << min.to_s }
    end'.should_not reek
  end

  it 'should report nested iterators only once per method' do
    'def bad(fred)
      @fred.each {|item| item.each {|part| @joe.send} }
      @jim.each {|ting| ting.each {|piece| @hal.send} }
    end'.should reek_only_of(:NestedIterators)
  end
end

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
kevinrutherford-reek-0.3.1.4 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-0.3.1.5 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-0.3.1.6 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.0.0 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.0.1 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.1 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.2.1 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.2 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.1 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.10 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.11 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.12 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.13 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.14 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.15 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.16 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.2 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.3 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.4 spec/reek/smells/nested_iterators_spec.rb
kevinrutherford-reek-1.1.3.5 spec/reek/smells/nested_iterators_spec.rb