Sha256: 18eda21278a26a29c0a49e4cc9bf399742c64b7c06eb2bb2d0c5802c47732a63

Contents?: true

Size: 707 Bytes

Versions: 33

Compression:

Stored size: 707 Bytes

Contents

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

require 'reek/smells/control_couple'

include Reek::Smells

describe ControlCouple do
  it 'should report a ternary check on a parameter' do
    'def simple(arga) arga ? @ivar : 3 end'.should reek_of(:ControlCouple, /arga/)
  end

  it 'should not report a ternary check on an ivar' do
    'def simple(arga) @ivar ? arga : 3 end'.should_not reek
  end

  it 'should not report a ternary check on a lvar' do
    'def simple(arga) lvar = 27; lvar ? arga : @ivar end'.should_not reek
  end

  it 'should spot a couple inside a block' do
    'def blocks(arg) @text.map { |blk| arg ? blk : "#{blk}" } end'.should reek_of(:ControlCouple, /arg/)
  end
end

Version data entries

33 entries across 33 versions & 3 rubygems

Version Path
kevinrutherford-reek-0.3.1.4 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-0.3.1.5 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-0.3.1.6 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.0.0 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.0.1 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.1 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.2.1 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.2 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.1 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.10 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.11 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.12 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.13 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.14 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.15 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.16 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.2 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.3 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.4 spec/reek/smells/control_couple_spec.rb
kevinrutherford-reek-1.1.3.5 spec/reek/smells/control_couple_spec.rb