Sha256: c6899f49cb4fc0174fa62faf704638fb8b65d118442e23e30bd1b0df0759abf0

Contents?: true

Size: 1.09 KB

Versions: 14

Compression:

Stored size: 1.09 KB

Contents

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

RSpec.describe Reek::Smells::UncommunicativeMethodName do
  let(:detector) { build(:smell_detector, smell_type: :UncommunicativeMethodName) }

  it_should_behave_like 'SmellDetector'

  ['help', '+', '-', '/', '*'].each do |method_name|
    it "accepts the method name '#{method_name}'" do
      src = "def #{method_name}(arg) basics(17) end"
      expect(src).not_to reek_of(:UncommunicativeMethodName)
    end
  end

  ['x', 'x2', 'method2'].each do |method_name|
    context 'with a bad name' do
      let(:warning) do
        src = "def #{method_name}; end"
        ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
        detector.inspect(ctx).first
      end

      it_should_behave_like 'common fields set correctly'

      it 'reports the correct values' do
        expect(warning.parameters[:name]).to eq(method_name)
        expect(warning.lines).to eq([1])
        expect(warning.context).to eq(method_name)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
reek-4.0.0.pre1 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.11 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.10.2 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.10.1 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.10.0 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.9.1 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.9.0 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.8.3 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.8.2 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.8.1 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.8.0 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.7.1 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.7.0 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.6.1 spec/reek/smells/uncommunicative_method_name_spec.rb