From d40ff9c3903daaa3a1fdf48d78bf3aba22674e8e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 24 Jan 2014 12:58:01 -0800 Subject: [PATCH] kernel_v2: test for box_url --- plugins/kernel_v2/config/vm.rb | 4 +--- templates/locales/en.yml | 1 - test/unit/plugins/kernel_v2/config/vm_test.rb | 19 ++++++++++++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 55d8dc752..308e6a0af 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -329,9 +329,7 @@ module VagrantPlugins end # Make sure the box URL is an array if it is set - if @box_url && !@box_url.is_a?(Array) - @box_url = [@box_url] - end + @box_url = Array(@box_url) if @box_url # Set the guest properly @guest = @guest.to_sym if @guest diff --git a/templates/locales/en.yml b/templates/locales/en.yml index e0ce29031..0a7763c43 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1329,7 +1329,6 @@ en: destroying: "Deleting box '%{name}'..." download: cleaning: "Cleaning up downloaded box..." - downloading: "Downloading box from URL: %{url}" download_failed: |- Download failed. Will try another box URL if there is one. interrupted: "Box download was interrupted. Exiting." diff --git a/test/unit/plugins/kernel_v2/config/vm_test.rb b/test/unit/plugins/kernel_v2/config/vm_test.rb index 9eaf0473c..205597f09 100644 --- a/test/unit/plugins/kernel_v2/config/vm_test.rb +++ b/test/unit/plugins/kernel_v2/config/vm_test.rb @@ -33,10 +33,27 @@ describe VagrantPlugins::Kernel_V2::VMConfig do end describe "#box_url" do - it "defaults properly" do + it "defaults to nil" do subject.finalize! + expect(subject.box_url).to be_nil end + + it "turns into an array" do + subject.box_url = "foo" + subject.finalize! + + expect(subject.box_url).to eq( + ["foo"]) + end + + it "keeps in array" do + subject.box_url = ["foo", "bar"] + subject.finalize! + + expect(subject.box_url).to eq( + ["foo", "bar"]) + end end context "#box_version" do