Cleaned up the `vagrant init` command, updated CHANGELOG
This commit is contained in:
parent
423e50fa6e
commit
992bd13b19
|
@ -1,6 +1,7 @@
|
||||||
## 0.5.2 (unreleased)
|
## 0.5.2 (unreleased)
|
||||||
|
|
||||||
|
- Added ability to specify box url in `init`, which populates the
|
||||||
|
Vagrantfile with the proper `config.vm.box_url`.
|
||||||
|
|
||||||
## 0.5.1 (July 31, 2010)
|
## 0.5.1 (July 31, 2010)
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,7 @@ module Vagrant
|
||||||
description "Initializes current folder for Vagrant usage"
|
description "Initializes current folder for Vagrant usage"
|
||||||
|
|
||||||
def execute(args)
|
def execute(args)
|
||||||
if args.empty?
|
create_vagrantfile(:default_box => args[0] , :default_box_url => args[1])
|
||||||
create_vagrantfile
|
|
||||||
else
|
|
||||||
create_vagrantfile(:default_box => args[0] , :default_box_url => args[1])
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def options_spec(opts)
|
def options_spec(opts)
|
||||||
|
@ -30,10 +25,10 @@ module Vagrant
|
||||||
error_and_exit(:rootfile_already_exists) if File.exist?(rootfile_path)
|
error_and_exit(:rootfile_already_exists) if File.exist?(rootfile_path)
|
||||||
|
|
||||||
# Write the rootfile
|
# Write the rootfile
|
||||||
default_opts = { :default_box => "base", :default_box_url => nil}.merge(opts)
|
opts = { :default_box => "base", :default_box_url => nil}.merge(opts)
|
||||||
|
|
||||||
File.open(rootfile_path, 'w+') do |f|
|
File.open(rootfile_path, 'w+') do |f|
|
||||||
f.write(TemplateRenderer.render(Environment::ROOTFILE_NAME, :default_box => default_opts[:default_box], :default_box_url => default_opts[:default_box_url]))
|
f.write(TemplateRenderer.render(Environment::ROOTFILE_NAME, opts))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,9 +11,9 @@ class CommandsInitTest < Test::Unit::TestCase
|
||||||
context "execute" do
|
context "execute" do
|
||||||
should "create a vagrant file without any args" do
|
should "create a vagrant file without any args" do
|
||||||
args = []
|
args = []
|
||||||
@instance.expects(:create_vagrantfile).with(nil)
|
@instance.expects(:create_vagrantfile).with(:default_box => nil, :default_box_url => nil)
|
||||||
@instance.execute(args)
|
@instance.execute(args)
|
||||||
end
|
end
|
||||||
context "when any arg is provided" do
|
context "when any arg is provided" do
|
||||||
should "create the vagrant file using the first arg as default_box and the second as default_box_url" do
|
should "create the vagrant file using the first arg as default_box and the second as default_box_url" do
|
||||||
args = []
|
args = []
|
||||||
|
@ -23,7 +23,7 @@ class CommandsInitTest < Test::Unit::TestCase
|
||||||
@instance.expects(:create_vagrantfile).with(:default_box => "foo", :default_box_url => "foo.box")
|
@instance.expects(:create_vagrantfile).with(:default_box => "foo", :default_box_url => "foo.box")
|
||||||
@instance.execute(args)
|
@instance.execute(args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "creating the vagrantfile" do
|
context "creating the vagrantfile" do
|
||||||
|
@ -58,10 +58,10 @@ class CommandsInitTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "use the box_url if given" do
|
should "use the box_url if given" do
|
||||||
box_url = "fubar.box"
|
box_url = "fubar.box"
|
||||||
Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => "base", :default_box_url => "fubar.box")
|
Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => "base", :default_box_url => "fubar.box")
|
||||||
@instance.create_vagrantfile :default_box_url => box_url
|
@instance.create_vagrantfile :default_box_url => box_url
|
||||||
end
|
end
|
||||||
|
|
||||||
should "use the default `base` if no box is given" do
|
should "use the default `base` if no box is given" do
|
||||||
Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => "base", :default_box_url => nil)
|
Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => "base", :default_box_url => nil)
|
||||||
|
|
Loading…
Reference in New Issue