Sha256: 0fff534f6947bf8bf7eb4c551ca2d43b55d8b6849e43d78e888b53a23a855e8b

Contents?: true

Size: 1.43 KB

Versions: 8

Compression:

Stored size: 1.43 KB

Contents

# encoding: utf-8

require 'spec_helper'
require 'stringio'
require 'tempfile'

module Rubocop
  module Formatter
    describe OffenceCountFormatter do
      subject(:formatter) { described_class.new(output) }
      let(:output) { StringIO.new }

      let(:files) do
        %w(lib/rubocop.rb spec/spec_helper.rb bin/rubocop).map do |path|
          File.expand_path(path)
        end
      end

      describe '#file_finished' do
        before { formatter.started(files) }

        let(:finish) { formatter.file_finished(files.first, offences) }

        context 'when no offences are detected' do
          let(:offences) { [] }
          it 'shouldn\'t add to offence_counts' do
            expect { finish }.to_not change { formatter.offence_counts }
          end
        end

        context 'when any offences are detected' do
          let(:offences) { [double('offence', cop_name: 'OffendedCop')] }
          it 'should increment the count for the cop in offence_counts' do
            expect { finish }.to change { formatter.offence_counts }
          end
        end
      end

      describe '#report_summary' do
        context 'when a offence detected' do
          let(:cop_counts) { { 'OffendedCop' => 1 } }
          it 'shows the cop and the offence count' do
            formatter.report_summary(1, cop_counts)
            expect(output.string).to include(
              "\n1  OffendedCop")
          end
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
ridecharge-rubocop-0.0.1 spec/rubocop/formatter/offence_count_formatter_spec.rb
rubocop-0.18.1 spec/rubocop/formatter/offence_count_formatter_spec.rb
rubocop-0.18.0 spec/rubocop/formatter/offence_count_formatter_spec.rb
rubocop-0.17.0 spec/rubocop/formatter/offence_count_formatter_spec.rb
rubocop-0.16.0 spec/rubocop/formatter/offence_count_formatter_spec.rb
rubocop-0.15.0 spec/rubocop/formatter/offence_count_formatter_spec.rb
rubocop-0.14.1 spec/rubocop/formatter/offence_count_formatter_spec.rb
rubocop-0.14.0 spec/rubocop/formatter/offence_count_formatter_spec.rb