Make init respect the env's cwd.
This commit is contained in:
parent
1f8c9673e5
commit
0c2fc0cae2
|
@ -7,7 +7,7 @@ module Vagrant
|
|||
register "init [box_name] [box_url]", "Initializes the current folder for Vagrant usage"
|
||||
|
||||
def execute
|
||||
template "Vagrantfile.erb", "Vagrantfile"
|
||||
template "Vagrantfile.erb", env.cwd.join("Vagrantfile")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -84,6 +84,29 @@ module Vagrant
|
|||
[app, env]
|
||||
end
|
||||
|
||||
# Utility method for capturing output streams.
|
||||
# @example Evaluate the output
|
||||
# output = capture(:stdout){ env.cli("foo") }
|
||||
# assert_equal "bar", output
|
||||
# @example Silence the output
|
||||
# silence(:stdout){ env.cli("init") }
|
||||
# @param [:stdout, :stderr] stream The stream to capture
|
||||
# @yieldreturn String
|
||||
# @see https://github.com/wycats/thor/blob/master/spec/spec_helper.rb
|
||||
def capture(stream)
|
||||
begin
|
||||
stream = stream.to_s
|
||||
eval "$#{stream} = StringIO.new"
|
||||
yield
|
||||
result = eval("$#{stream}").string
|
||||
ensure
|
||||
eval("$#{stream} = #{stream.upcase}")
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
alias :silence :capture
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Path helpers
|
||||
#------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
require "test_helper"
|
||||
|
||||
class CommandInitCommandTest < Test::Unit::TestCase
|
||||
should "create a Vagrantfile in the environment's cwd" do
|
||||
path = vagrant_app
|
||||
env = Vagrant::Environment.new(:cwd => path)
|
||||
silence(:stdout) { env.cli("init") }
|
||||
assert File.exist?(path.join("Vagrantfile"))
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue