Update `init` command unit tests to reflect new --template option
This commit is contained in:
parent
14d596f08e
commit
968fbb2399
|
@ -37,6 +37,30 @@ describe VagrantPlugins::CommandInit::Command do
|
|||
expect(contents).to_not match(/provision/)
|
||||
end
|
||||
|
||||
it "creates a custom Vagrantfile using a relative template path" do
|
||||
described_class.new(["--template", "test/unit/templates/commands/init/Vagrantfile"], env).execute
|
||||
contents = File.read(vagrantfile_path)
|
||||
expect(contents).to match(/config.vm.hostname = "vagrant.dev"/)
|
||||
end
|
||||
|
||||
it "creates a custom Vagrantfile using an absolute template path" do
|
||||
described_class.new(["--template", ::Vagrant.source_root.join("test/unit/templates/commands/init/Vagrantfile").to_s], env).execute
|
||||
contents = File.read(vagrantfile_path)
|
||||
expect(contents).to match(/config.vm.hostname = "vagrant.dev"/)
|
||||
end
|
||||
|
||||
it "creates a custom Vagrantfile using a provided template with the extension included" do
|
||||
described_class.new(["--template", ::Vagrant.source_root.join("test/unit/templates/commands/init/Vagrantfile.erb").to_s], env).execute
|
||||
contents = File.read(vagrantfile_path)
|
||||
expect(contents).to match(/config.vm.hostname = "vagrant.dev"/)
|
||||
end
|
||||
|
||||
it "ignores the -m option when using a provided template" do
|
||||
described_class.new(["-m", "--template", ::Vagrant.source_root.join("test/unit/templates/commands/init/Vagrantfile").to_s], env).execute
|
||||
contents = File.read(vagrantfile_path)
|
||||
expect(contents).to match(/config.vm.hostname = "vagrant.dev"/)
|
||||
end
|
||||
|
||||
it "does not overwrite an existing Vagrantfile" do
|
||||
# Create an existing Vagrantfile
|
||||
File.open(File.join(env.cwd, "Vagrantfile"), "w+") { |f| f.write("") }
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.hostname = "vagrant.dev"
|
||||
config.vm.box = "<%= box_name %>"
|
||||
<% if box_version -%>
|
||||
config.vm.box_version = "<%= box_version %>"
|
||||
<% end -%>
|
||||
|
||||
<% if box_url -%>
|
||||
# The url from where the 'config.vm.box' box will be fetched if it
|
||||
# doesn't already exist on the user's system.
|
||||
config.vm.box_url = "<%= box_url %>"
|
||||
<% end -%>
|
||||
end
|
Loading…
Reference in New Issue