test/vagrant/action/vm/provision_test.rb in vagrant-0.5.4 vs test/vagrant/action/vm/provision_test.rb in vagrant-0.6.0
- old
+ new
@@ -1,11 +1,11 @@
require "test_helper"
class ProvisionVMActionTest < Test::Unit::TestCase
setup do
@klass = Vagrant::Action::VM::Provision
- @app, @env = mock_action_data
+ @app, @env = action_env
@vm = mock("vm")
@vm.stubs(:name).returns("foo")
@vm.stubs(:ssh).returns(mock("ssh"))
@vm.stubs(:system).returns(mock("system"))
@@ -63,13 +63,14 @@
@instance.load_provisioner
end
should "error environment if the class is not a subclass of the provisioner base" do
@prov.expects(:is_a?).with(Vagrant::Provisioners::Base).returns(false)
- @instance.load_provisioner
- assert @env.error?
- assert_equal :provisioner_invalid_class, @env.error.first
+
+ assert_raises(Vagrant::Errors::ProvisionInvalidClass) {
+ @instance.load_provisioner
+ }
end
end
context "with a Symbol provisioner" do
def provisioner_expectation(symbol, provisioner)
@@ -79,15 +80,16 @@
instance.expects(:prepare).once
provisioner.expects(:new).with(@env).returns(instance)
assert_equal instance, @instance.load_provisioner
end
- should "raise an ActionException if its an unknown symbol" do
+ should "raise an error if its an unknown symbol" do
@env["config"].vm.provisioner = :this_will_never_exist
- @instance.load_provisioner
- assert @env.error?
- assert_equal :provisioner_unknown_type, @env.error.first
+
+ assert_raises(Vagrant::Errors::ProvisionUnknownType) {
+ @instance.load_provisioner
+ }
end
should "set :chef_solo to the ChefSolo provisioner" do
provisioner_expectation(:chef_solo, Vagrant::Provisioners::ChefSolo)
end
@@ -113,18 +115,9 @@
@instance.call(@env)
end
should "continue chain and not provision if not enabled" do
@env["config"].vm.provisioner = nil
- @prov.expects(:provision!).never
- @app.expects(:call).with(@env).once
-
- @instance.call(@env)
- end
-
- should "not provision if erroneous environment" do
- @env.error!(:foo)
-
@prov.expects(:provision!).never
@app.expects(:call).with(@env).once
@instance.call(@env)
end