Sha256: 7af8eb3afad4a085a43572d08ff27aa7a7d83f8cb533879d734ebd7978599ac0
Contents?: true
Size: 1.51 KB
Versions: 3
Compression:
Stored size: 1.51 KB
Contents
require 'hound/tools/hound_overrides' require_relative 'template_spec' RSpec.describe Hound::Tools::HoundOverrides do filename = '.hound/overrides.yml' it_behaves_like 'a template', filename describe '#generate' do before do allow(IO).to receive(:read). with(/lib\/hound\/tools\/templates\/_#{filename}$/).and_call_original allow($stderr).to receive(:puts) allow($stdout).to receive(:puts) allow(FileUtils).to receive(:mkpath).with('.hound') end context "with no #{filename}" do before do allow(IO).to receive(:read).with(filename).and_raise(Errno::ENOENT) allow(IO).to receive(:write).with(filename, anything) end it "creates a valid #{filename} file" do expect(IO).to receive(:write).with(filename, anything) do |_file, data| expect(data).to be config = YAML::load(data) expect(config).to be expect(config['AllCops']).to include('Exclude' => %w(db/schema.rb Gemfile Rakefile)) end subject.generate end end context "with existing invalid #{filename}" do let(:contents) { 'foo: :bar' } before { allow(IO).to receive(:read).with(filename).and_return(contents) } it 'returns false' do expect(subject.generate).to be_falsey end it 'displays the file already exists' do msg = "Error: #{filename} is invalid! (No AllCops section)" expect($stderr).to receive(:puts).with(msg) subject.generate end end end end
Version data entries
3 entries across 3 versions & 1 rubygems