From 1c480880f14458a245c81e7ea0e0df8b4c366d00 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Wed, 10 Oct 2018 10:30:30 -0700 Subject: [PATCH] Add test coverage of local rgloader creation --- lib/vagrant/environment.rb | 2 +- test/unit/vagrant/environment_test.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 961c16e75..acda45278 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -910,7 +910,7 @@ module Vagrant loader_file = @local_data_path.join("rgloader", "loader.rb") if !loader_file.file? source_loader = Vagrant.source_root.join("templates/rgloader.rb") - FileUtils.mkdir_p(@local_data_path.join("rgloader")) + FileUtils.mkdir_p(@local_data_path.join("rgloader").to_s) FileUtils.cp(source_loader.to_s, loader_file.to_s) end rescue Errno::EACCES diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 215d61ae8..6c92cd5ba 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -1513,4 +1513,21 @@ VF end end end + + describe "#setup_local_data_path" do + before do + allow(FileUtils).to receive(:mkdir_p).and_call_original + allow(FileUtils).to receive(:cp).and_call_original + end + + it "should create an rgloader path" do + expect(FileUtils).to receive(:mkdir_p).with(/(?!home)rgloader/) + instance + end + + it "should write the rgloader file" do + expect(FileUtils).to receive(:cp).with(anything, /(?!home)rgloader.*rb$/) + instance + end + end end