Sha256: 7994a297e53ba69f0d78cf37f4fc0733104fcba6911e40d8e7566529ac1f4168
Contents?: true
Size: 1.73 KB
Versions: 6
Compression:
Stored size: 1.73 KB
Contents
require_relative '../../spec_helper' require 'tailor/critic' require 'tailor/configuration/style' METHOD_LENGTH = {} METHOD_LENGTH[:method_too_long] = %Q{def thing puts puts end} METHOD_LENGTH[:parent_method_too_long] = %Q{def thing puts def inner_thing; print '1'; end puts end} describe "Detection of method length" do before do Tailor::Logger.stub(:log) FakeFS.activate! File.open(file_name.to_s, 'w') { |f| f.write contents } critic.check_file(file_name.to_s, style.to_hash) end let(:critic) do Tailor::Critic.new end let(:contents) { METHOD_LENGTH[file_name] } let(:style) do style = Tailor::Configuration::Style.new style.trailing_newlines 0, level: :off style.allow_invalid_ruby true, level: :off style.max_code_lines_in_method 3 style end context "single class too long" do let(:file_name) { :method_too_long } specify { critic.problems[file_name.to_s].size.should be 1 } specify { critic.problems[file_name.to_s].first[:type].should == "max_code_lines_in_method" } specify { critic.problems[file_name.to_s].first[:line].should be 1 } specify { critic.problems[file_name.to_s].first[:column].should be 0 } specify { critic.problems[file_name.to_s].first[:level].should be :error } end context "method in a method" do let(:file_name) { :method_too_long } specify { critic.problems[file_name.to_s].size.should be 1 } specify { critic.problems[file_name.to_s].first[:type].should == "max_code_lines_in_method" } specify { critic.problems[file_name.to_s].first[:line].should be 1 } specify { critic.problems[file_name.to_s].first[:column].should be 0 } specify { critic.problems[file_name.to_s].first[:level].should be :error } end end
Version data entries
6 entries across 6 versions & 1 rubygems