Sha256: 478d755b6d743dd898e99e8fec23093ef3c88bc39b867f168f18e546351d2c0e
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
require_relative '../../spec_helper' require_lib 'reek/smells/too_many_statements' RSpec.describe Reek::Smells::TooManyStatements do let(:config) do { Reek::Smells::TooManyStatements::MAX_ALLOWED_STATEMENTS_KEY => 2 } end it 'reports the right values' do src = <<-EOS class Alfa def bravo charlie = 1 delta = 2 echo = 3 end end EOS expect(src).to reek_of(:TooManyStatements, lines: [2], context: 'Alfa#bravo', message: 'has approx 3 statements', source: 'string', count: 3).with_config(config) end it 'does count all occurences' do src = <<-EOS class Alfa def bravo charlie = 1 delta = 2 echo = 3 end def foxtrot golf = 1 hotel = 2 india = 3 end end EOS expect(src). to reek_of(:TooManyStatements, lines: [2], context: 'Alfa#bravo').with_config(config). and reek_of(:TooManyStatements, lines: [8], context: 'Alfa#foxtrot').with_config(config) end it 'does not report short methods' do src = <<-EOS class Alfa def bravo charlie = 1 delta = 2 end end EOS expect(src).not_to reek_of(:TooManyStatements).with_config(config) end it 'does not report initialize' do src = <<-EOS class Alfa def initialize charlie = 1 delta = 2 echo = 3 end end EOS expect(src).not_to reek_of(:TooManyStatements).with_config(config) end it 'reports long inner block' do src = <<-EOS def long self.each do |x| charlie = 1 delta = 2 echo = 3 end end EOS expect(src).to reek_of(:TooManyStatements).with_config(config) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reek-4.4.2 | spec/reek/smells/too_many_statements_spec.rb |