Sha256: fea76c40927bec2f4efb65306811a1a626d749491a1e128cf0632460e971a7bc

Contents?: true

Size: 1.68 KB

Versions: 16

Compression:

Stored size: 1.68 KB

Contents

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

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

    it "sets the type as 'issue'" do
      expect(json['type']).to eq 'issue'
    end

    it 'sets the category' do
      expect(json['categories']).to eq ['Complexity']
    end

    it 'constructs a description based on the context and message' do
      expect(json['description']).to eq 'context foo message bar'
    end

    it 'sets a check name based on the smell detector' do
      expect(json['check_name']).to eq 'UtilityFunction'
    end

    it 'sets the location' do
      expect(json['location']).to eq('path' => 'a/ruby/source/file.rb',
                                     'lines' => { 'begin' => 1, 'end' => 2 })
    end

    it 'sets a content based on the smell detector' do
      expect(json['content']['body']).
        to eq "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(json['remediation_points']).to eq 250_000
    end

    it 'sets fingerprint based on warning context' do
      expect(json['fingerprint']).to eq '70c530e45999af129d520f1f579f967f'
    end
  end
end

Version data entries

16 entries across 14 versions & 2 rubygems

Version Path
reek-5.4.0 spec/reek/report/code_climate/code_climate_formatter_spec.rb
reek-5.3.2 spec/reek/report/code_climate/code_climate_formatter_spec.rb
reek-5.3.1 spec/reek/report/code_climate/code_climate_formatter_spec.rb
reek-5.3.0 spec/reek/report/code_climate/code_climate_formatter_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/report/code_climate/code_climate_formatter_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/report/code_climate/code_climate_formatter_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/report/code_climate/code_climate_formatter_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/report/code_climate/code_climate_formatter_spec.rb
reek-5.2.0 spec/reek/report/code_climate/code_climate_formatter_spec.rb
reek-5.1.0 spec/reek/report/code_climate/code_climate_formatter_spec.rb
reek-5.0.2 spec/reek/report/code_climate/code_climate_formatter_spec.rb
reek-5.0.1 spec/reek/report/code_climate/code_climate_formatter_spec.rb
reek-5.0.0 spec/reek/report/code_climate/code_climate_formatter_spec.rb
reek-4.8.2 spec/reek/report/code_climate/code_climate_formatter_spec.rb
reek-4.8.1 spec/reek/report/code_climate/code_climate_formatter_spec.rb
reek-4.8.0 spec/reek/report/code_climate/code_climate_formatter_spec.rb