Sha256: 485d0facd4ec556f072f3ee0a0cb446a19abfe42a2c5aa37bcdb19347290f280

Contents?: true

Size: 1.61 KB

Versions: 2

Compression:

Stored size: 1.61 KB

Contents

# encoding: utf-8

require 'spec_helper'
require 'stringio'
require 'ostruct'

module Rubocop
  module Formatter
    describe DisabledConfigFormatter do
      subject(:formatter) { DisabledConfigFormatter.new(output) }
      let(:output) do
        o = StringIO.new
        def o.path
          'rubocop-todo.yml'
        end
        o
      end
      let(:offences) do
        [Rubocop::Cop::Offence.new(:convention, location, 'message', 'Cop1'),
         Rubocop::Cop::Offence.new(:convention, location, 'message', 'Cop2')]
      end
      let(:location) { OpenStruct.new(line: 1, column: 5) }
      before { $stdout = StringIO.new }

      describe '#finished' do
        it 'displays YAML configuration disabling all cops with offences' do
          formatter.file_finished('test.rb', offences)
          formatter.finished(['test.rb'])
          expect(output.string).to eq(DisabledConfigFormatter::HEADING +
                                      ['',
                                       '',
                                       'Cop1:',
                                       '  Enabled: false',
                                       '',
                                       'Cop2:',
                                       '  Enabled: false',
                                       ''].join("\n"))
          expect($stdout.string)
            .to eq(['Created rubocop-todo.yml.',
                    'Run rubocop with --config rubocop-todo.yml, or',
                    'add inherit_from: rubocop-todo.yml in a .rubocop.yml ' +
                    'file.',
                    ''].join("\n"))
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.13.1 spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.13.0 spec/rubocop/formatter/disabled_config_formatter_spec.rb