Action.run can be called with a class
This commit is contained in:
parent
086ca5a97e
commit
e9bcd3fc16
|
@ -43,6 +43,7 @@ module Vagrant
|
|||
#
|
||||
# @param [Object] callable An object which responds to `call`.
|
||||
def run(callable, options=nil)
|
||||
callable = Builder.new.use(callable) if callable.kind_of?(Class)
|
||||
callable = self.class.actions[callable] if callable.kind_of?(Symbol)
|
||||
|
||||
action_environment = Action::Environment.new(env)
|
||||
|
|
|
@ -71,6 +71,19 @@ class ActionTest < Test::Unit::TestCase
|
|||
@instance.run(:call)
|
||||
end
|
||||
|
||||
should "run the given class if a class is given" do
|
||||
callable = Class.new do
|
||||
def initialize(app, env); end
|
||||
end
|
||||
|
||||
callable.any_instance.expects(:call).with() do |env|
|
||||
assert_equal :foo, env[:bar]
|
||||
true
|
||||
end
|
||||
|
||||
@instance.run(callable, :bar => :foo)
|
||||
end
|
||||
|
||||
should "error and exit if erroneous environment results" do
|
||||
callable = lambda do |env|
|
||||
env.error!(:key, :foo => :bar)
|
||||
|
|
Loading…
Reference in New Issue