require 'spec_helper' require 'reek/smells/too_many_statements' require 'reek/core/code_parser' require 'reek/core/sniffer' require 'reek/smells/smell_detector_shared' include Reek include Reek::Smells def process_method(src) source = src.to_reek_source sniffer = Core::Sniffer.new(source) Core::CodeParser.new(sniffer).process_defn(source.syntax_tree) end def process_singleton_method(src) source = src.to_reek_source sniffer = Core::Sniffer.new(source) Core::CodeParser.new(sniffer).process_defs(source.syntax_tree) end describe TooManyStatements do it 'should not report short methods' do src = 'def short(arga) alf = f(1);@bet = 2;@cut = 3;@dit = 4; @emp = 5;end' src.should_not smell_of(TooManyStatements) end it 'should report long methods' do src = 'def long() alf = f(1);@bet = 2;@cut = 3;@dit = 4; @emp = 5;@fry = 6;end' src.should reek_only_of(:TooManyStatements, /6 statements/) end it 'should not report initialize' do src = 'def initialize(arga) alf = f(1);@bet = 2;@cut = 3;@dit = 4; @emp = 5;@fry = 6;end' src.should_not smell_of(TooManyStatements) end it 'should only report a long method once' do src = <