Sha256: ce4db9d44d2969ce02c8a6d338831789b253ab03555df048b0f1ebb7b0c08bf8

Contents?: true

Size: 1.22 KB

Versions: 8

Compression:

Stored size: 1.22 KB

Contents

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

RSpec.describe Reek::Smells::UncommunicativeMethodName do
  before do
    @source_name = 'dummy_source'
    @detector = build(:smell_detector, smell_type: :UncommunicativeMethodName, source: @source_name)
  end

  it_should_behave_like 'SmellDetector'

  ['help', '+', '-', '/', '*'].each do |method_name|
    it "accepts the method name '#{method_name}'" do
      src = "def #{method_name}(fred) 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
      before do
        src = "def #{method_name}; end"
        ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
        smells = @detector.examine_context(ctx)
        @warning = smells[0]
      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

8 entries across 8 versions & 1 rubygems

Version Path
reek-3.2.1 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.2 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.1 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.0.4 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.0.3 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.0.2 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.0.1 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-3.0.0 spec/reek/smells/uncommunicative_method_name_spec.rb