test/vagrant/action_test.rb in vagrant-0.5.4 vs test/vagrant/action_test.rb in vagrant-0.6.0
- old
+ new
@@ -5,11 +5,11 @@
@klass = Vagrant::Action
end
context "with a class" do
teardown do
- @klass.actions.clear
+ @klass.actions.delete(:foo)
end
should "be able to register an action" do
@klass.register(:foo, :bar)
assert @klass.actions.has_key?(:foo)
@@ -22,20 +22,16 @@
end
end
context "with an instance" do
setup do
- @instance = @klass.new(mock_environment)
+ @instance = @klass.new(vagrant_env)
end
- teardown do
- @klass.actions.clear
- end
-
should "raise an exception if a nil action is given" do
- assert_raises(Vagrant::Exceptions::UncallableAction) { @instance.run(nil) }
- assert_raises(Vagrant::Exceptions::UncallableAction) { @instance.run(:dontexist) }
+ assert_raises(ArgumentError) { @instance.run(nil) }
+ assert_raises(ArgumentError) { @instance.run(:dontexist) }
end
should "run the callable item with the proper context" do
callable = mock("callable")
callable.expects(:call).with() do |env|
@@ -72,10 +68,11 @@
callable = mock("callable")
callable.expects(:call).once
@klass.register(:call, callable)
@instance.run(:call)
+ @klass.actions.delete(:call)
end
should "run the given class if a class is given" do
callable = Class.new do
def initialize(app, env); end
@@ -85,27 +82,8 @@
assert_equal :foo, env[:bar]
true
end
@instance.run(callable, :bar => :foo)
- end
-
- should "exit if environment was marked as interrupted" do
- callable = lambda do |env|
- env.error!(:interrupt)
- end
-
- @instance.stubs(:error_and_exit)
- @instance.expects(:exit).once
- @instance.run(callable)
- end
-
- should "error and exit if erroneous environment results" do
- callable = lambda do |env|
- env.error!(:key, :foo => :bar)
- end
-
- @instance.expects(:error_and_exit).with(:key, :foo => :bar)
- @instance.run(callable)
end
end
end