From 26b3a303d2705adf29dc16c3ee56308cd9889f90 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Thu, 6 Oct 2016 16:15:53 -0700 Subject: [PATCH] config/vm: cast box version to string before string operations --- plugins/kernel_v2/config/vm.rb | 2 +- test/unit/plugins/kernel_v2/config/vm_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 0cb7c8b1b..fcd8da3bf 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -581,7 +581,7 @@ module VagrantPlugins @hostname && @hostname !~ /^[a-z0-9][-.a-z0-9]*$/i if @box_version - @box_version.split(",").each do |v| + @box_version.to_s.split(",").each do |v| begin Gem::Requirement.new(v.strip) rescue Gem::Requirement::BadRequirementError diff --git a/test/unit/plugins/kernel_v2/config/vm_test.rb b/test/unit/plugins/kernel_v2/config/vm_test.rb index bef729832..b8320cfc7 100644 --- a/test/unit/plugins/kernel_v2/config/vm_test.rb +++ b/test/unit/plugins/kernel_v2/config/vm_test.rb @@ -133,6 +133,14 @@ describe VagrantPlugins::Kernel_V2::VMConfig do assert_valid end + + ["1", 1, "1.0", 1.0].each do |valid| + it "is valid: #{valid}" do + subject.box_version = valid + subject.finalize! + assert_valid + end + end end describe "#communicator" do