Sha256: 835a037ade982aeea37a4023dad45729438cc5b5ce8956939eb4eeeaf821d3ed

Contents?: true

Size: 1.36 KB

Versions: 11

Compression:

Stored size: 1.36 KB

Contents

require_relative '../../spec_helper'
require_lib 'reek/smell_detectors/missing_safe_method'

RSpec.describe Reek::SmellDetectors::MissingSafeMethod do
  it 'reports the right values' do
    src = <<-EOS
      class Alfa
        def bravo!
        end
      end
    EOS

    expect(src).to reek_of(:MissingSafeMethod,
                           lines:   [2],
                           context: 'Alfa',
                           message: "has missing safe method 'bravo!'",
                           source:  'string',
                           name:    'bravo!')
  end

  it 'does count all occurences' do
    src = <<-EOS
      class Alfa
        def bravo!
        end

        def charlie!
        end
      end
    EOS

    expect(src).
      to reek_of(:MissingSafeMethod, lines: [2], name: 'bravo!').
      and reek_of(:MissingSafeMethod, lines: [5], name: 'charlie!')
  end

  it 'reports nothing when method and bang counterpart exist' do
    src = <<-EOS
      class Alfa
        def bravo
        end

        def bravo!
        end
      end
    EOS

    expect(src).not_to reek_of(:MissingSafeMethod)
  end

  it 'does not report methods we excluded via comment' do
    source = <<-EOF
      # :reek:MissingSafeMethod: { exclude: [ bravo! ] }
      class Alfa
        def bravo!
        end
      end
    EOF

    expect(source).not_to reek_of(:MissingSafeMethod)
  end
end

Version data entries

11 entries across 9 versions & 2 rubygems

Version Path
reek-5.3.1 spec/reek/smell_detectors/missing_safe_method_spec.rb
reek-5.3.0 spec/reek/smell_detectors/missing_safe_method_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_detectors/missing_safe_method_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_detectors/missing_safe_method_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_detectors/missing_safe_method_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/smell_detectors/missing_safe_method_spec.rb
reek-5.2.0 spec/reek/smell_detectors/missing_safe_method_spec.rb
reek-5.1.0 spec/reek/smell_detectors/missing_safe_method_spec.rb
reek-5.0.2 spec/reek/smell_detectors/missing_safe_method_spec.rb
reek-5.0.1 spec/reek/smell_detectors/missing_safe_method_spec.rb
reek-5.0.0 spec/reek/smell_detectors/missing_safe_method_spec.rb