Sha256: 3687227875592e2de208b069e61cf44a4cec8edc3ff5bcbdabec19c316fd663e

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'
require 'reek/examiner'
require 'reek/cli/report'
require 'rainbow'
require 'stringio'

include Reek
include Reek::Cli

describe QuietReport, " when empty" do
  context 'empty source' do
    it 'has an empty quiet_report' do
      examiner = Examiner.new('')
      qr = QuietReport.new
      qr.add_examiner(examiner)
      qr.gather_results.should == []
    end
  end

  context 'with a couple of smells' do
    before :each do
      @examiner = Examiner.new('def simple(a) a[3] end')
      @rpt = QuietReport.new(SimpleWarningFormatter, ReportFormatter, false, :text)
    end

    context 'with colors disabled' do
      before :each do
        Rainbow.enabled = false
        @result = @rpt.add_examiner(@examiner).gather_results.first
      end

      it 'has a header' do
        @result.should match('string -- 2 warnings')
      end

      it 'should mention every smell name' do
        @result.should match('[UncommunicativeParameterName]')
        @result.should match('[Feature Envy]')
      end
    end

    context 'with colors enabled' do
      before :each do
        Rainbow.enabled = true
        @rpt.add_examiner(Examiner.new('def simple(a) a[3] end'))
        @rpt.add_examiner(Examiner.new('def simple(a) a[3] end'))
        @result = @rpt.gather_results
      end

      it 'has a header in color' do
        @result.first.should start_with "\e[36mstring -- \e[0m\e[33m2 warning\e[0m\e[33ms\e[0m"
      end

      it 'has a footer in color' do
        stdout = StringIO.new
        $stdout = stdout
        @rpt.show
        $stdout = STDOUT

        stdout.string.should end_with "\e[31m4 total warnings\n\e[0m"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reek-1.3.8 spec/reek/cli/report_spec.rb
reek-1.3.7 spec/reek/cli/report_spec.rb