Clear forwarded ports to the modify pipeline

This commit is contained in:
Mitchell Hashimoto 2011-07-08 12:02:35 -07:00
parent 6b2feae0e8
commit 027b22eca0
2 changed files with 10 additions and 5 deletions

View File

@ -4,11 +4,10 @@ module Vagrant
class ClearForwardedPorts
def initialize(app, env)
@app = app
@env = env
end
def call(env)
env["config"].vm.customize do |vm|
proc = lambda do |vm|
env.ui.info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
vm.network_adapters.each do |na|
@ -18,6 +17,7 @@ module Vagrant
end
end
env["vm.modify"].call(proc)
@app.call(env)
end
end

View File

@ -8,6 +8,7 @@ class ClearForwardedPortsVMActionTest < Test::Unit::TestCase
@vm = mock("vm")
@vm.stubs(:name).returns("foo")
@env["vm"] = @vm
@env["vm.modify"] = mock("proc")
@instance = @klass.new(@app, @env)
end
@ -36,10 +37,14 @@ class ClearForwardedPortsVMActionTest < Test::Unit::TestCase
end
should "call the proper methods and continue chain" do
@env["config"].vm.expects(:customize).yields(@internal_vm)
@adapters << mock_adapter
@adapters << mock_adapter
@env["vm.modify"].expects(:call).with() do |proc|
proc.call(@internal_vm)
true
end
@adapters << mock_adapter
@adapters << mock_adapter
@app.expects(:call).with(@env)
@instance.call(@env)
end