Sha256: 24c3917d31a9f0fcbe3c116f3d3ede76c339a7e4916e2e9f4d9b8c263b4e2c21

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'
require 'reek/smells/module_initialize'
require 'reek/smells/smell_detector_shared'

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

4 entries across 4 versions & 1 rubygems

Version Path
reek-2.0.4 spec/reek/smells/module_initialize_spec.rb
reek-2.0.3 spec/reek/smells/module_initialize_spec.rb
reek-2.0.2 spec/reek/smells/module_initialize_spec.rb
reek-2.0.1 spec/reek/smells/module_initialize_spec.rb