Sha256: b544b76c40db4e0637e104d6f6bd368fdb6c0d1363ee67e3dad467e2c36465a1
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require_relative '../../spec_helper' require_lib 'reek/smells/too_many_constants' RSpec.describe Reek::Smells::ManualDispatch do it 'reports the right values' do src = <<-EOS class Alfa def bravo(charlie) true if charlie.respond_to?(:to_a) end end EOS expect(src).to reek_of(:ManualDispatch, lines: [3], context: 'Alfa#bravo', message: 'manually dispatches method call', source: 'string') end it 'does count all occurences' do src = <<-EOS class Alfa def bravo(charlie) true if charlie.respond_to?(:to_a) end def delta(echo) true if echo.respond_to?(:to_a) end end EOS expect(src). to reek_of(:ManualDispatch, lines: [3], context: 'Alfa#bravo'). and reek_of(:ManualDispatch, lines: [7], context: 'Alfa#delta') end it 'reports manual dispatch smell when using #respond_to? on implicit self' do src = <<-EOS class Alfa def bravo charlie if respond_to?(:delta) end end EOS expect(src).to reek_of(:ManualDispatch) end it 'reports manual dispatch within a conditional' do src = <<-EOS class Alfa def bravo charlie.respond_to?(:delta) && charlie.echo end end EOS expect(src).to reek_of(:ManualDispatch) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reek-4.4.2 | spec/reek/smells/manual_dispatch_spec.rb |