Box destroy works again
This commit is contained in:
parent
d92f3d8c6d
commit
d9321ed4d4
|
@ -10,8 +10,8 @@ module Vagrant
|
|||
end
|
||||
|
||||
def call(env)
|
||||
env.ui.info I18n.t("vagrant.actions.box.destroy.destroying", :name => env["box"].name)
|
||||
FileUtils.rm_rf(env["box"].directory)
|
||||
env[:ui].info I18n.t("vagrant.actions.box.destroy.destroying", :name => env[:box_name])
|
||||
FileUtils.rm_rf(env[:box_directory])
|
||||
|
||||
@app.call(env)
|
||||
end
|
||||
|
|
|
@ -7,10 +7,7 @@ module Vagrant
|
|||
# is kicked out to middlewares.
|
||||
class Box
|
||||
# The name of the box.
|
||||
attr_accessor :name
|
||||
|
||||
# The URI for a new box. This is not available for existing boxes.
|
||||
attr_accessor :uri
|
||||
attr_reader :name
|
||||
|
||||
# The directory where this box is stored
|
||||
attr_reader :directory
|
||||
|
@ -21,14 +18,15 @@ module Vagrant
|
|||
#
|
||||
# **Note:** This method does not actually _create_ the box, but merely
|
||||
# returns a new, abstract representation of it. To add a box, see {#add}.
|
||||
def initialize(name, directory)
|
||||
def initialize(name, directory, action_runner)
|
||||
@name = name
|
||||
@directory = directory
|
||||
@action_runner = action_runner
|
||||
end
|
||||
|
||||
# Begins the process of destroying this box. This cannot be undone!
|
||||
def destroy
|
||||
env.actions.run(:box_remove, { "box" => self, "validate" => false })
|
||||
@action_runner.run(:box_remove, { :box_name => @name, :box_directory => @directory })
|
||||
end
|
||||
|
||||
# Begins sequence to repackage this box.
|
||||
|
|
|
@ -47,7 +47,7 @@ module Vagrant
|
|||
Dir.open(@directory) do |dir|
|
||||
dir.each do |d|
|
||||
next if d == "." || d == ".." || !@directory.join(d).directory?
|
||||
@boxes << Box.new(d, @directory.join(d))
|
||||
@boxes << Box.new(d, @directory.join(d), @action_runner)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
require File.expand_path("../../base", __FILE__)
|
||||
|
||||
describe Vagrant::Box do
|
||||
let(:name) { "foo" }
|
||||
let(:directory) { "bar" }
|
||||
let(:action_runner) { double("action_runner") }
|
||||
let(:instance) { described_class.new(name, directory, action_runner) }
|
||||
|
||||
it "provides the name" do
|
||||
instance.name.should == name
|
||||
end
|
||||
|
||||
it "can destroy itself" do
|
||||
# Simply test the messages to the action runner
|
||||
options = {
|
||||
:box_name => name,
|
||||
:box_directory => directory
|
||||
}
|
||||
action_runner.should_receive(:run).with(:box_remove, options)
|
||||
|
||||
instance.destroy
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue