Sha256: 16b9f2c3bfba229b4a7de0ba388e19a0cfd4c17e9b5ddefbd4009576f2b5f9c8

Contents?: true

Size: 1.71 KB

Versions: 13

Compression:

Stored size: 1.71 KB

Contents

# encoding: utf-8

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

module RuboCop
  module Formatter
    describe DisabledConfigFormatter do
      subject(:formatter) { described_class.new(output) }
      let(:output) do
        o = StringIO.new
        def o.path
          '.rubocop_todo.yml'
        end
        o
      end
      let(:offenses) do
        [RuboCop::Cop::Offense.new(:convention, location, 'message', 'Cop1'),
         RuboCop::Cop::Offense.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 offenses' do
          formatter.file_finished('test.rb', offenses)
          formatter.finished(['test.rb'])
          expect(output.string).to eq(described_class::HEADING +
                                      ['',
                                       '',
                                       '# Offense count: 1',
                                       'Cop1:',
                                       '  Enabled: false',
                                       '',
                                       '# Offense count: 1',
                                       'Cop2:',
                                       '  Enabled: false',
                                       ''].join("\n"))
          expect($stdout.string)
            .to eq(['Created .rubocop_todo.yml.',
                    'Run `rubocop --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

13 entries across 13 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.29.1 spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.29.0 spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.28.0 spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.27.1 spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.27.0 spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.26.1 spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.26.0 spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.25.0 spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.24.1 spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.24.0 spec/rubocop/formatter/disabled_config_formatter_spec.rb
rubocop-0.23.0 spec/rubocop/formatter/disabled_config_formatter_spec.rb