Sha256: d14fb9e8ff21d5f2987d1577b4f6cdfff454d337b23ccbe18c36f08bc4171e91
Contents?: true
Size: 1.19 KB
Versions: 14
Compression:
Stored size: 1.19 KB
Contents
# encoding: utf-8 module StatementModifierHelper def check_empty(cop, keyword) inspect_source(cop, ["#{keyword} cond", 'end']) expect(cop.offenses).to be_empty end def check_really_short(cop, keyword) inspect_source(cop, ["#{keyword} a", ' b', 'end']) expect(cop.messages).to eq( ["Favor modifier `#{keyword}` usage when having a single-line body."]) expect(cop.offenses.map { |o| o.location.source }).to eq([keyword]) end def check_too_long(cop, keyword) # This statement is one character too long to fit. condition = 'a' * (40 - keyword.length) body = 'b' * 37 expect(" #{body} #{keyword} #{condition}".length).to eq(81) inspect_source(cop, [" #{keyword} #{condition}", " #{body}", ' end']) expect(cop.offenses).to be_empty end def check_short_multiline(cop, keyword) inspect_source(cop, ["#{keyword} ENV['COVERAGE']", " require 'simplecov'", ' SimpleCov.start', 'end']) expect(cop.messages).to be_empty end end
Version data entries
14 entries across 14 versions & 2 rubygems