Tests for multivagrantfile being found
This commit is contained in:
parent
3fdc3bee4b
commit
4f30a834d0
|
@ -495,7 +495,7 @@ module Vagrant
|
||||||
if current_path.exist?
|
if current_path.exist?
|
||||||
# We also test if current_path == path because on case insensitive
|
# We also test if current_path == path because on case insensitive
|
||||||
# file systems, it will look like multiple exist.
|
# file systems, it will look like multiple exist.
|
||||||
if path && current_path == path
|
if path && current_path != path
|
||||||
raise Errors::MultiVagrantfileFound, :directory => search_path.to_s
|
raise Errors::MultiVagrantfileFound, :directory => search_path.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,13 @@ require "support/isolated_environment"
|
||||||
|
|
||||||
module Unit
|
module Unit
|
||||||
class IsolatedEnvironment < ::IsolatedEnvironment
|
class IsolatedEnvironment < ::IsolatedEnvironment
|
||||||
def create_vagrant_env
|
def create_vagrant_env(options=nil)
|
||||||
Vagrant::Environment.new(:cwd => @workdir, :home_path => @homedir)
|
options = {
|
||||||
|
:cwd => @workdir,
|
||||||
|
:home_path => @homedir
|
||||||
|
}.merge(options || {})
|
||||||
|
|
||||||
|
Vagrant::Environment.new(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def vagrantfile(contents, root=nil)
|
def vagrantfile(contents, root=nil)
|
||||||
|
@ -22,6 +27,7 @@ module Unit
|
||||||
box_dir = boxes_dir.join(name)
|
box_dir = boxes_dir.join(name)
|
||||||
box_dir.mkpath
|
box_dir.mkpath
|
||||||
vagrantfile(vagrantfile_contents, box_dir)
|
vagrantfile(vagrantfile_contents, box_dir)
|
||||||
|
box_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
def boxes_dir
|
def boxes_dir
|
||||||
|
|
|
@ -151,6 +151,26 @@ VF
|
||||||
env = environment.create_vagrant_env
|
env = environment.create_vagrant_env
|
||||||
env.config.for_vm(:default).ssh.port.should == 100
|
env.config.for_vm(:default).ssh.port.should == 100
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should error if the box has an ambiguous Vagrantfile" do
|
||||||
|
environment = isolated_environment do |env|
|
||||||
|
env.vagrantfile(<<-VF)
|
||||||
|
Vagrant::Config.run do |config|
|
||||||
|
config.vm.box = "base"
|
||||||
|
end
|
||||||
|
VF
|
||||||
|
|
||||||
|
# Create two Vagrantfiles. The normal one and a Vagrantfile2
|
||||||
|
box_dir = env.box("base", "")
|
||||||
|
box_dir.join("Vagrantfile2").open("w") do |f|
|
||||||
|
f.write("")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
env = environment.create_vagrant_env(:vagrantfile_name => ["Vagrantfile", "Vagrantfile2"])
|
||||||
|
expect { env.config }.
|
||||||
|
to raise_error(Vagrant::Errors::MultiVagrantfileFound)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "ui" do
|
describe "ui" do
|
||||||
|
|
Loading…
Reference in New Issue