Sha256: 9e99447fcc7274cfd87a2298cc905eacdaf831ce1e1746bb2b746508bddbe484

Contents?: true

Size: 1.03 KB

Versions: 33

Compression:

Stored size: 1.03 KB

Contents

require_relative '../../spec_helper'
require_lib 'reek/smells/module_initialize'
require_relative 'smell_detector_shared'

RSpec.describe Reek::Smells::ModuleInitialize do
  context 'module' do
    context 'with method named initialize' do
      it 'smells' do
        src = <<-EOF
          module A
            def initialize; end
          end
        EOF
        expect(src).to reek_of(:ModuleInitialize)
      end
    end

    context 'with method named initialize in a nested class' do
      it 'does not smell' do
        src = <<-EOF
          module A
            class B
              def initialize; end
            end
          end
        EOF
        expect(src).not_to reek_of(:ModuleInitialize)
      end
    end

    context 'with method named initialize in a nested struct' do
      it 'does not smell' do
        src = <<-EOF
          module A
            B = Struct.new(:c) do
              def initialize; end
            end
          end
        EOF
        expect(src).not_to reek_of(:ModuleInitialize)
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
reek-4.4.0 spec/reek/smells/module_initialize_spec.rb
reek-4.3.0 spec/reek/smells/module_initialize_spec.rb
reek-4.2.5 spec/reek/smells/module_initialize_spec.rb
reek-4.2.4 spec/reek/smells/module_initialize_spec.rb
reek-4.2.3 spec/reek/smells/module_initialize_spec.rb
reek-4.2.2 spec/reek/smells/module_initialize_spec.rb
reek-4.2.1 spec/reek/smells/module_initialize_spec.rb
reek-4.2.0 spec/reek/smells/module_initialize_spec.rb
reek-4.1.1 spec/reek/smells/module_initialize_spec.rb
reek-4.1.0 spec/reek/smells/module_initialize_spec.rb
reek-4.0.5 spec/reek/smells/module_initialize_spec.rb
reek-4.0.4 spec/reek/smells/module_initialize_spec.rb
reek-4.0.3 spec/reek/smells/module_initialize_spec.rb
reek-4.0.2 spec/reek/smells/module_initialize_spec.rb
reek-4.0.1 spec/reek/smells/module_initialize_spec.rb
reek-4.0.0 spec/reek/smells/module_initialize_spec.rb
reek-4.0.0.pre1 spec/reek/smells/module_initialize_spec.rb
reek-3.11 spec/reek/smells/module_initialize_spec.rb
reek-3.10.2 spec/reek/smells/module_initialize_spec.rb
reek-3.10.1 spec/reek/smells/module_initialize_spec.rb