Sha256: 7a2333cb6cea5b920c80410f6446e124afe2c982bd8b97a451a625d0b145b67f

Contents?: true

Size: 867 Bytes

Versions: 11

Compression:

Stored size: 867 Bytes

Contents

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

describe Roodi::Checks::NpathComplexityMethodCheck do
  before(:each) do
    @roodi = Roodi::Core::Runner.new(Roodi::Checks::NpathComplexityMethodCheck.make({'complexity' => 0}))
  end

  def verify_content_complexity(content, complexity)
    @roodi.check_content(content)
    errors = @roodi.errors
    errors.should_not be_empty
    errors[0].to_s.should eql("dummy-file.rb:1 - Method name \"method_name\" n-path complexity is #{complexity}.  It should be 0 or less.")
  end
  
  it "should default to 1" do
    content = <<-END
    def method_name
    end
    END
    verify_content_complexity(content, 1)
  end
  
  it "should find an if block" do
    content = <<-END
    def method_name
      call_foo if some_condition
    end
    END
    verify_content_complexity(content, 2)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
roodi-5.0.0 spec/roodi/checks/npath_complexity_method_check_spec.rb
roodi-4.1.1 spec/roodi/checks/npath_complexity_method_check_spec.rb
roodi-4.1.0 spec/roodi/checks/npath_complexity_method_check_spec.rb
roodi-4.0.0 spec/roodi/checks/npath_complexity_method_check_spec.rb
roodi-3.3.1 spec/roodi/checks/npath_complexity_method_check_spec.rb
roodi-3.3.0 spec/roodi/checks/npath_complexity_method_check_spec.rb
roodi-3.2.0 spec/roodi/checks/npath_complexity_method_check_spec.rb
roodi-3.1.1 spec/roodi/checks/npath_complexity_method_check_spec.rb
roodi-3.1.0 spec/roodi/checks/npath_complexity_method_check_spec.rb
roodi-3.0.1 spec/roodi/checks/npath_complexity_method_check_spec.rb
roodi-3.0.0 spec/roodi/checks/npath_complexity_method_check_spec.rb