spec/lib/gumboot/strap_spec.rb in aaf-gumboot-1.0.0.pre.alpha.2 vs spec/lib/gumboot/strap_spec.rb in aaf-gumboot-1.1.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'spec_helper' require 'mysql2' require 'gumboot/strap' @@ -125,11 +127,11 @@ expect(ActiveRecord::Base).to receive_message_chain(:connection, :execute) .with('SHOW TABLES').and_return(tables) end context 'when a database already exists' do - let(:tables) { %w(schema_migrations) } + let(:tables) { %w[schema_migrations] } it 'runs the migrations' do expect(subject.kernel).to receive(:system).with('rake db:migrate') subject.maintain_activerecord_schema end @@ -177,23 +179,23 @@ expect(FileUtils).to receive(:ln_s).with("#{base}/a", 'config/a') expect(FileUtils).to receive(:ln_s).with("#{base}/b", 'config/b') expect(FileUtils).to receive(:ln_s).with("#{base}/c", 'config/c') - subject.link_global_configuration(%w(a b c)) + subject.link_global_configuration(%w[a b c]) end it 'skips an existing file' do allow(File).to receive(:exist?).and_return(true) expect(FileUtils).not_to receive(:ln_s) - subject.link_global_configuration(%w(a)) + subject.link_global_configuration(%w[a]) end it 'raises an error for a missing file' do allow(File).to receive(:exist?).and_return(false) - expect { subject.link_global_configuration(%w(a)) } + expect { subject.link_global_configuration(%w[a]) } .to raise_error(/Missing global config file/) end end context '#update_local_configuration' do @@ -221,11 +223,11 @@ subject.update_local_configuration([file]) end def updated_config expect(written).not_to be_empty - YAML.load(written.join) + YAML.safe_load(written.join, [Symbol]) end context 'when the target does not exist' do it 'creates the target' do run @@ -282,9 +284,19 @@ context 'when the dist file is missing' do let(:dist) { nil } it 'raises an error' do expect { run }.to raise_error(/Missing dist config file/) + end + end + + context 'when the files contain symbol keys' do + let(:dist) { YAML.dump(a: 2) } + let(:target) { YAML.dump(a: 3) } + + it 'merges the new configuration option' do + run + expect(updated_config).to eq(a: 3) end end end describe '#install_dist_template' do