vagrant/test/acceptance/up_with_box_url.rb

41 lines
1.3 KiB
Ruby
Raw Normal View History

2011-11-22 05:55:03 +00:00
require File.expand_path("../base", __FILE__)
2011-12-11 23:53:11 +00:00
require "acceptance/support/shared/command_examples"
2011-11-22 05:55:03 +00:00
describe "vagrant up", "with a box URL set" do
include_context "acceptance"
it "downloads and brings up the VM if the box doesn't exist" do
require_box("default")
assert_execute("vagrant", "init", "base", box_path("default"))
result = assert_execute("vagrant", "up")
result.stdout.should match_output(:up_fetching_box, "base")
end
it "downloads the file only once and works if shared by multiple VMs", :issue => "GH-564" do
2011-11-22 05:55:03 +00:00
require_box("default")
environment.workdir.join("Vagrantfile").open("w+") do |f|
f.puts(<<-VFILE)
Vagrant::Config.run do |config|
config.vm.define :machine1 do |vm_config|
vm_config.vm.box = "base"
vm_config.vm.box_url = "#{box_path("default")}"
end
config.vm.define :machine2 do |vm_config|
vm_config.vm.box = "base"
vm_config.vm.box_url = "#{box_path("default")}"
end
end
VFILE
end
2011-11-22 06:09:51 +00:00
# Bring up the environment, which should work. `machine1` should download
# the box while `machine2` doesn't.
2011-11-22 05:55:03 +00:00
result = assert_execute("vagrant", "up")
2011-11-22 06:09:51 +00:00
result.stdout.should match_output(:up_fetching_box, "base", "machine1")
result.stdout.should_not match_output(:up_fetching_box, "base", "machine2")
2011-11-22 05:55:03 +00:00
end
end