Sha256: 75f233c0eb8435aa18923fcb895b00cd40cbf006044137c2ceabe44abccbdb94

Contents?: true

Size: 910 Bytes

Versions: 7

Compression:

Stored size: 910 Bytes

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

require 'reek/smells/simulated_polymorphism'

include Reek::Smells

describe SimulatedPolymorphism do
  it 'should report 3 similar conditions in a class' do
    src = <<EOS
class Scrunch
  def first
    return @field == :sym ? 0 : 3;
  end
  def second
    if @field == :sym
      @other += " quarts"
    end
  end
  def third
    raise 'flu!' unless @field == :sym
  end
end
EOS

    src.should reek_only_of(:SimulatedPolymorphism, /@field == :sym/)
  end

  it 'should include case statements in the count' do
    src = <<EOS
class Scrunch
  def first
    return @field ? 0 : 3;
  end
  def second
    case @field
    when :sym
      @other += " quarts"
    end
  end
  def third
    raise 'flu!' unless @field
  end
end
EOS

    src.should reek_only_of(:SimulatedPolymorphism, /@field/)
  end

  # And count code in superclasses, if we have it
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
kevinrutherford-reek-1.1.3.14 spec/reek/smells/simulated_polymorphism_spec.rb
kevinrutherford-reek-1.1.3.15 spec/reek/smells/simulated_polymorphism_spec.rb
kevinrutherford-reek-1.1.3.16 spec/reek/smells/simulated_polymorphism_spec.rb
kevinrutherford-reek-1.2.0 spec/reek/smells/simulated_polymorphism_spec.rb
reek-1.2.2 spec/reek/smells/simulated_polymorphism_spec.rb
reek-1.2.1 spec/reek/smells/simulated_polymorphism_spec.rb
reek-1.2.0 spec/reek/smells/simulated_polymorphism_spec.rb