diff --git a/CHANGELOG.md b/CHANGELOG.md index effe43e3c..a4532244d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ possible load errors. [GH-781] - `vagrant destroy` shows a nice error when called without a TTY (and hence can't confirm). [GH-779] + - Fix an issue with the `:vagrantfile_name` option to `Vagrant::Environment` + not working properly. [GH-778] ## 1.0.0 (March 6, 2012) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index ce4b97f2e..f11923ee2 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -59,10 +59,11 @@ module Vagrant opts[:cwd] ||= Dir.pwd opts[:cwd] = Pathname.new(opts[:cwd]) - # Set the default vagrantfile name, which can be either Vagrantfile - # or vagrantfile (capital for backwards compatibility) - opts[:vagrantfile_name] ||= ["Vagrantfile", "vagrantfile"] + # Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that + # those continue to work as well, but anything custom will take precedence. + opts[:vagrantfile_name] ||= [] opts[:vagrantfile_name] = [opts[:vagrantfile_name]] if !opts[:vagrantfile_name].is_a?(Array) + opts[:vagrantfile_name] += ["Vagrantfile", "vagrantfile"] # Set instance variables for all the configuration parameters. @cwd = opts[:cwd] diff --git a/test/unit/support/isolated_environment.rb b/test/unit/support/isolated_environment.rb index 51beaffc3..c7435ea9a 100644 --- a/test/unit/support/isolated_environment.rb +++ b/test/unit/support/isolated_environment.rb @@ -16,6 +16,14 @@ module Unit Vagrant::Environment.new(options) end + # This creates a file in the isolated environment. By default this file + # will be created in the working directory of the isolated environment. + def file(name, contents) + @workdir.join(name).open("w+") do |f| + f.write(contents) + end + end + def vagrantfile(contents, root=nil) root ||= @workdir root.join("Vagrantfile").open("w+") do |f| diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 738b469e3..4a51047c4 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -120,6 +120,19 @@ VF env.config.global.vagrant.dotfile_name.should == "foo" end + it "should load from a custom Vagrantfile" do + environment = isolated_environment do |env| + env.file("non_standard_name", <<-VF) +Vagrant::Config.run do |config| + config.vagrant.dotfile_name = "custom" +end +VF + end + + env = environment.create_vagrant_env(:vagrantfile_name => "non_standard_name") + env.config.global.vagrant.dotfile_name.should == "custom" + end + it "should load VM configuration" do environment = isolated_environment do |env| env.vagrantfile(<<-VF)