diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index dc2d7a8a1..b92b00748 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -272,6 +272,7 @@ module Vagrant # against the given name will be run in the context of this environment. # # @param [Symbol] name Name of the hook. + # @param [Action::Runner] action_runner A custom action runner for running hooks. def hook(name, runner = action_runner) @logger.info("Running hook: #{name}") callable = Action::Builder.new diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 5f571f7cb..07bd261fa 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -308,6 +308,14 @@ describe Vagrant::Environment do instance.hook(:bar).should == :foo end + + it "should allow passing in a custom action runner" do + instance.action_runner.should_not_receive(:run) + other_runner = mock + other_runner.should_receive(:run).with(:bar).and_return(:foo) + + instance.hook(:bar, other_runner).should == :foo + end end describe "primary machine name" do