Sha256: a64fb858c3ae3fbd8fd68813278aee84bb413d514a9de2dd0261ad3422c7b016

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 Bytes

Contents

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

require 'reek/method_checker'
require 'reek/report'

include Reek

describe MethodChecker, "(Control Couple)" do

  before(:each) do
    @rpt = Report.new
    @cchk = MethodChecker.new(@rpt, 'Thing')
  end

  it 'should report a ternary check on a parameter' do
    @cchk.check_source('def simple(arga) arga ? @ivar : 3 end')
    @rpt.length.should == 1
    ControlCouple.should === @rpt[0]
    @rpt[0].to_s.should match(/arga/)
  end

  it 'should not report a ternary check on an ivar' do
    @cchk.check_source('def simple(arga) @ivar ? arga : 3 end')
    @rpt.should be_empty
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reek-0.3.0 spec/reek/control_couple_spec.rb