Sha256: 90594d5f5993c4b5051b7a06fe02f5c4efd5ae3c060b2cefc286e7b6809dfedc

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

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

require 'reek/code_parser'
require 'reek/report'

include Reek

describe LongMethod do
  it 'should not report short methods' do
    'def short(arga) alf = f(1);@bet = 2;@cut = 3;@dit = 4; @emp = 5;end'.should_not reek
  end

  it 'should report long methods' do
    'def long(arga) alf = f(1);@bet = 2;@cut = 3;@dit = 4; @emp = 5;@fry = 6;end'.should reek_only_of(:LongMethod, /6 statements/)
  end

  it 'should not report initialize' do
    'def initialize(arga) alf = f(1);@bet = 2;@cut = 3;@dit = 4; @emp = 5;@fry = 6;end'.should_not reek
  end

  it 'should only report a long method once' do
    source =<<EOS
def standard_entries(rbconfig)
  @abc = rbconfig
  rubypath = File.join(@abc['bindir'], @abcf['ruby_install_name'] + cff['EXEEXT'])
  major = yyy['MAJOR'].to_i
  minor = zzz['MINOR'].to_i
  teeny = ccc['TEENY'].to_i
  version = ""
  if c['rubylibdir']
    @libruby         = "/lib/ruby"
    @librubyver      = "/lib/ruby/"
    @librubyverarch  = "/lib/ruby/"
    @siteruby        = "lib/ruby/version/site_ruby"
    @siterubyver     = siteruby
    @siterubyverarch = "$siterubyver/['arch']}"
  end
end
EOS
    source.should reek_only_of(:LongMethod)
  end

  it 'should report long inner block' do
    src = <<EOS
def long(arga)
  f(3)
  self.each do |xyzero|
    xyzero = 1
    xyzero = 2
    xyzero = 3
    xyzero = 4
    xyzero = 5
    xyzero = 6
  end
end
EOS
    src.should reek_only_of(:LongMethod)
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
kevinrutherford-reek-1.1.1 spec/reek/smells/long_method_spec.rb
kevinrutherford-reek-1.1.2.1 spec/reek/smells/long_method_spec.rb
kevinrutherford-reek-1.1.2 spec/reek/smells/long_method_spec.rb
kevinrutherford-reek-1.1.3 spec/reek/smells/long_method_spec.rb
reek-1.1.3 spec/reek/smells/long_method_spec.rb