Sha256: 9b41e6a39b61122d8aa6b856f782e3fd705df8433f297ff7c3d0b647ade3c688

Contents?: true

Size: 712 Bytes

Versions: 1

Compression:

Stored size: 712 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_only_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

1 entries across 1 versions & 1 rubygems

Version Path
reek-1.2.3 spec/reek/smells/control_couple_spec.rb