Sha256: 3c7af83627c9d09a12518db5cb309c8b38bec028cb92dd430cc1f8c9783ff243

Contents?: true

Size: 1.56 KB

Versions: 4

Compression:

Stored size: 1.56 KB

Contents

require_relative '../../spec_helper'
require_lib 'reek/report/code_climate/code_climate_formatter'

RSpec.describe Reek::Report::CodeClimateFormatter, '#render' do
  let(:warning) do
    FactoryGirl.build(:smell_warning,
                      smell_detector: Reek::Smells::UtilityFunction.new,
                      context:        'context foo',
                      message:        'message bar',
                      lines:          [1, 2],
                      source:         'a/ruby/source/file.rb')
  end
  let(:rendered) { Reek::Report::CodeClimateFormatter.new(warning).render }

  it "sets the type as 'issue'" do
    expect(rendered).to match(/\"type\":\"issue\"/)
  end

  it 'sets the category' do
    expect(rendered).to match(/\"categories\":\[\"Complexity\"\]/)
  end

  it 'constructs a description based on the context and message' do
    expect(rendered).to match(/\"description\":\"context foo message bar\"/)
  end

  it 'sets a check name based on the smell detector' do
    expect(rendered).to match(%r{\"check_name\":\"LowCohesion\/UtilityFunction\"})
  end

  it 'sets the location' do
    expect(rendered).to match(%r{\"location\":{\"path\":\"a/ruby/source/file.rb\",\"lines\":{\"begin\":1,\"end\":2}}})
  end

  it 'sets a content based on the smell detector' do
    expect(rendered).to match(
      /\"body\":\"A _Utility Function_ is any instance method that has no dependency on the state of the instance.\\n\"/
    )
  end

  it 'sets remediation points based on the smell detector' do
    expect(rendered).to match(/\"remediation_points\":250000/)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reek-3.11 spec/reek/report/code_climate_formatter_spec.rb
reek-3.10.2 spec/reek/report/code_climate_formatter_spec.rb
reek-3.10.1 spec/reek/report/code_climate_formatter_spec.rb
reek-3.10.0 spec/reek/report/code_climate_formatter_spec.rb