Sha256: ba248eb3d5d91c933bcfe57a4c8378aafb3324de486119b279fbd73610da2241
Contents?: true
Size: 955 Bytes
Versions: 4
Compression:
Stored size: 955 Bytes
Contents
require File.dirname(__FILE__) + '/../spec_helper.rb' require 'reek/method_checker' require 'reek/report' include Reek describe MethodChecker, " nested iterators" do before(:each) do @rpt = Report.new @chk = MethodChecker.new(@rpt, 'Thing') end it "should report nested iterators in a method" do @chk.check_source('def bad(fred) @fred.each {|item| item.each {|ting| ting.ting} } end') @rpt.length.should == 1 end it "should not report method with successive iterators" do source =<<EOS def bad(fred) @fred.each {|item| item.each } @jim.each {|item| item.each } end EOS @chk.check_source(source) @rpt.should be_empty end it "should report nested iterators only once per method" do source =<<EOS def bad(fred) @fred.each {|item| item.each {|part| @jim.send} } @jim.each {|item| item.each {|piece| @fred.send} } end EOS @chk.check_source(source) @rpt.length.should == 1 end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
reek-0.1.1 | spec/reek/nested_iterators_spec.rb |
reek-0.2.0 | spec/reek/nested_iterators_spec.rb |
reek-0.2.1 | spec/reek/nested_iterators_spec.rb |
reek-0.2.2 | spec/reek/nested_iterators_spec.rb |