Sha256: c84e77467c59da967107f56bf3a114920691b617687292db3308f462407a0507

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

require 'hound/tools/merged_yml'

require_relative 'template_spec'

RSpec.describe Hound::Tools::MergedYml do
  filename = '.rubocop_merged_for_hound.yml'

  # it_behaves_like "a template", filename
  specify { expect(subject.filename).to eq(filename) }

  describe '#generate' do
    let(:hound_yml) { instance_double(Hound::Tools::HoundYml) }

    before do
      allow(Hound::Tools::HoundYml).to receive(:new).and_return(hound_yml)
      allow(hound_yml).to receive(:rubocop_filename).and_return(filename)

      allow(IO).to receive(:read).with('.hound/overrides.yml').and_return('foo')
      allow(IO).to receive(:read).with('.rubocop_todo.yml').and_return('bar')
      allow(FileUtils).to receive(:mkpath).with('.')

      allow(IO).to receive(:write).with(filename, anything)
    end

    it 'regenerates the file' do
      expected = <<-EOS.gsub(/^\s+/, '')
      # This is a file generated by `hound-tools`
      #
      # We don't include .hound/defaults.yml, because Hound has internally
      # loaded them at this point
      #
      # ---------------------------------
      # .hound/overrides.yml
      # ---------------------------------
      foo
      # ---------------------------------
      # .rubocop_todo.yml
      # ---------------------------------
      bar
      EOS
      expect(IO).to receive(:write).with(filename, anything) do |_, data|
        expect(data).to eq(expected)
      end

      subject.generate
    end

    it 'prints info about merging' do
      expect($stdout).to receive(:puts).with(/\.rubocop_merged_for_hound\.yml \(regenerated\)/)
      subject.generate
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hound-tools-0.0.6 spec/lib/hound/tools/merged_yml_spec.rb
hound-tools-0.0.5 spec/lib/hound/tools/merged_yml_spec.rb
hound-tools-0.0.4 spec/lib/hound/tools/merged_yml_spec.rb