Provision action must call "prepare" on the provisioner

This commit is contained in:
Mitchell Hashimoto 2010-03-10 15:12:45 -08:00
parent 2763540b44
commit 759d904628
2 changed files with 16 additions and 1 deletions

View File

@ -32,7 +32,8 @@ module Vagrant
@provisioner = provisioner_klass.new @provisioner = provisioner_klass.new
end end
logger.info "Provisioning enabld with #{@provisioner.class}" logger.info "Provisioning enabled with #{@provisioner.class}"
@provisioner.prepare
end end
def execute! def execute!

View File

@ -44,6 +44,7 @@ class ProvisionActionTest < Test::Unit::TestCase
setup do setup do
@instance = mock("instance") @instance = mock("instance")
@instance.stubs(:is_a?).with(Vagrant::Provisioners::Base).returns(true) @instance.stubs(:is_a?).with(Vagrant::Provisioners::Base).returns(true)
@instance.stubs(:prepare)
@klass = mock("klass") @klass = mock("klass")
@klass.stubs(:is_a?).with(Class).returns(true) @klass.stubs(:is_a?).with(Class).returns(true)
@klass.stubs(:new).returns(@instance) @klass.stubs(:new).returns(@instance)
@ -59,6 +60,11 @@ class ProvisionActionTest < Test::Unit::TestCase
assert_equal @instance, @action.provisioner assert_equal @instance, @action.provisioner
end end
should "call prepare on the instance" do
@instance.expects(:prepare).once
@action.prepare
end
should "raise an exception if the class is not a subclass of the provisioner base" do should "raise an exception if the class is not a subclass of the provisioner base" do
@instance.expects(:is_a?).with(Vagrant::Provisioners::Base).returns(false) @instance.expects(:is_a?).with(Vagrant::Provisioners::Base).returns(false)
assert_raises(Vagrant::Actions::ActionException) { assert_raises(Vagrant::Actions::ActionException) {
@ -90,6 +96,14 @@ class ProvisionActionTest < Test::Unit::TestCase
should "set :chef_solo to the ChefSolo provisioner" do should "set :chef_solo to the ChefSolo provisioner" do
provisioner_expectation(:chef_solo, Vagrant::Provisioners::ChefSolo) provisioner_expectation(:chef_solo, Vagrant::Provisioners::ChefSolo)
end end
should "call prepare on the instance" do
instance = mock("instance")
instance.expects(:prepare).once
instance.stubs(:is_a?).returns(true)
Vagrant::Provisioners::ChefSolo.expects(:new).returns(instance)
provisioner_expectation(:chef_solo, Vagrant::Provisioners::ChefSolo)
end
end end
end end
end end