Sha256: 5967616ad977e90af8b9aa55333cd1d7e3b7486ee748018b8fd87ea481031732

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

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

describe Roodi::Checks::CyclomaticComplexityBlockCheck do
  before(:each) do
    @roodi = Roodi::Core::ParseTreeRunner.new(Roodi::Checks::CyclomaticComplexityBlockCheck.new(0))
  end

  def verify_content_complexity(content, complexity)
    @roodi.check_content(content)
    errors = @roodi.errors
    errors.should_not be_empty
    errors[0].should eql("dummy-file.rb - Block cyclomatic complexity is #{complexity}.  It should be 0 or less.")
  end
  
  it "should find a simple block" do
    content = <<-END
    def method_name
      it "should be a complex block" do
        call_foo
      end
    end
    END
    verify_content_complexity(content, 1)
  end

  it "should find a block with multiple paths" do
    content = <<-END
    def method_name
      it "should be a complex block" do
        call_foo if some_condition
      end
    end
    END
    verify_content_complexity(content, 2)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roodi-1.0.0 spec/checks/cyclomatic_complexity_block_check_spec.rb