Sha256: 2c5fb24f98858777bbd2b5b18f8f1c159469ca992b69b793f466a397c8e828b7

Contents?: true

Size: 882 Bytes

Versions: 2

Compression:

Stored size: 882 Bytes

Contents

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

describe Simplabs::Excellent::Checks::ControlCouplingCheck do

  before(:each) do
    @excellent = Simplabs::Excellent::Core::ParseTreeRunner.new(Simplabs::Excellent::Checks::ControlCouplingCheck.new)
  end

  describe '#evaluate' do

    it 'should reject methods with if checks using a parameter' do
      content = <<-END
        def write(quoted, foo)
          if quoted
            write_quoted(@value)
          else
            puts @value
          end
        end
      END
      @excellent.check_content(content)
      errors = @excellent.errors

      errors.should_not be_empty
      errors[0].info.should        == { :method => :write, :argument => :quoted }
      errors[0].line_number.should == 2
      errors[0].message.should     == 'Control of write is coupled to quoted.'
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simplabs-excellent-1.0.0 spec/checks/control_coupling_check_spec.rb
simplabs-excellent-1.0.1 spec/checks/control_coupling_check_spec.rb