Sha256: 88aea652cc6860b846d1de168b787b1405a860c6b438f04ce6611c90d95e8c09

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'
require 'reek/smells/uncommunicative_method_name'
require 'reek/smells/smell_detector_shared'
require 'reek/core/code_parser'
require 'reek/core/sniffer'

include Reek
include Reek::Smells

describe UncommunicativeMethodName do
  before :each do
    @source_name = 'wallamalloo'
    @detector = UncommunicativeMethodName.new(@source_name)
  end

  it_should_behave_like 'SmellDetector'

  ['help', '+', '-', '/', '*'].each do |method_name|
    it "accepts the method name '#{method_name}'" do
      "def #{method_name}(fred) basics(17) end".should_not smell_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 = CodeContext.new(nil, src.to_reek_source.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
        @warning.smell[UncommunicativeMethodName::METHOD_NAME_KEY].should == method_name
        @warning.lines.should == [1]
        @warning.context.should == method_name
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reek-1.3.8 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-1.3.7 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-1.3.6 spec/reek/smells/uncommunicative_method_name_spec.rb
reek-1.3.5 spec/reek/smells/uncommunicative_method_name_spec.rb