Sha256: f79f1f2f78749e7e390a6fb6fd4ac080ccbe2a3f59c9d7411014c611024c63c8

Contents?: true

Size: 1.61 KB

Versions: 9

Compression:

Stored size: 1.61 KB

Contents

require_relative '../../spec_helper'
require_lib 'reek/examiner'
require_lib 'reek/report/yaml_report'

require 'yaml'
require 'stringio'

RSpec.describe Reek::Report::YAMLReport do
  let(:options) { {} }
  let(:instance) { described_class.new(options) }
  let(:examiner) { Reek::Examiner.new(source) }

  before do
    instance.add_examiner examiner
  end

  context 'with empty source' do
    let(:source) { '' }

    it 'prints empty yaml' do
      expect { instance.show }.to output(/^--- \[\]\n.*$/).to_stdout
    end
  end

  context 'with smelly source' do
    let(:source) { 'def simple(a) a[3] end' }

    it 'prints smells as yaml' do
      out = StringIO.new
      instance.show(out)
      out.rewind
      result = YAML.safe_load(out.read)
      expected = YAML.safe_load <<-EOS.strip_heredoc
        ---
        - context:        "simple"
          lines:
          - 1
          message:            "has the parameter name 'a'"
          smell_type:         "UncommunicativeParameterName"
          source:             "string"
          name:               "a"
          documentation_link: "https://github.com/troessner/reek/blob/v#{Reek::Version::STRING}/docs/Uncommunicative-Parameter-Name.md"
        - context:        "simple"
          lines:
          - 1
          message:            "doesn't depend on instance state (maybe move it to another class?)"
          smell_type:         "UtilityFunction"
          source:             "string"
          documentation_link: "https://github.com/troessner/reek/blob/v#{Reek::Version::STRING}/docs/Utility-Function.md"
      EOS

      expect(result).to eq expected
    end
  end
end

Version data entries

9 entries across 7 versions & 2 rubygems

Version Path
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/report/yaml_report_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/yaml_report_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/yaml_report_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/report/yaml_report_spec.rb
reek-5.2.0 spec/reek/report/yaml_report_spec.rb
reek-5.1.0 spec/reek/report/yaml_report_spec.rb
reek-5.0.2 spec/reek/report/yaml_report_spec.rb
reek-5.0.1 spec/reek/report/yaml_report_spec.rb
reek-5.0.0 spec/reek/report/yaml_report_spec.rb