Merge pull request #9784 from briancain/move-trigger-obj-init
Move triggers object init in machine
This commit is contained in:
commit
f43cacd36a
|
@ -110,6 +110,7 @@ module Vagrant
|
||||||
@ui = Vagrant::UI::Prefixed.new(@env.ui, @name)
|
@ui = Vagrant::UI::Prefixed.new(@env.ui, @name)
|
||||||
@ui_mutex = Mutex.new
|
@ui_mutex = Mutex.new
|
||||||
@state_mutex = Mutex.new
|
@state_mutex = Mutex.new
|
||||||
|
@triggers = Vagrant::Plugin::V2::Trigger.new(@env, @config.trigger, self)
|
||||||
|
|
||||||
# Read the ID, which is usually in local storage
|
# Read the ID, which is usually in local storage
|
||||||
@id = nil
|
@id = nil
|
||||||
|
@ -149,8 +150,6 @@ module Vagrant
|
||||||
# Output a bunch of information about this machine in
|
# Output a bunch of information about this machine in
|
||||||
# machine-readable format in case someone is listening.
|
# machine-readable format in case someone is listening.
|
||||||
@ui.machine("metadata", "provider", provider_name)
|
@ui.machine("metadata", "provider", provider_name)
|
||||||
|
|
||||||
@triggers = Vagrant::Plugin::V2::Trigger.new(@env, @config.trigger, self)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# This calls an action on the provider. The provider may or may not
|
# This calls an action on the provider. The provider may or may not
|
||||||
|
|
|
@ -50,7 +50,8 @@ describe Vagrant::Machine do
|
||||||
|
|
||||||
def new_provider_mock
|
def new_provider_mock
|
||||||
double("provider").tap do |obj|
|
double("provider").tap do |obj|
|
||||||
allow(obj).to receive(:_initialize).and_return(nil)
|
allow(obj).to receive(:_initialize)
|
||||||
|
.with(provider_name, anything).and_return(nil)
|
||||||
allow(obj).to receive(:machine_id_changed).and_return(nil)
|
allow(obj).to receive(:machine_id_changed).and_return(nil)
|
||||||
allow(obj).to receive(:state).and_return(Vagrant::MachineState.new(
|
allow(obj).to receive(:state).and_return(Vagrant::MachineState.new(
|
||||||
:created, "", ""))
|
:created, "", ""))
|
||||||
|
@ -76,6 +77,24 @@ describe Vagrant::Machine do
|
||||||
expect(subject.id).to be_nil
|
expect(subject.id).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "setting up triggers" do
|
||||||
|
before do
|
||||||
|
expect(provider).to receive(:_initialize) do |*args|
|
||||||
|
machine = args.last
|
||||||
|
@trigger_instance = machine.instance_variable_get(:@triggers)
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should initialize the trigger object" do
|
||||||
|
subject = new_instance
|
||||||
|
expect(subject.instance_variable_get(:@triggers))
|
||||||
|
.to be_a(Vagrant::Plugin::V2::Trigger)
|
||||||
|
expect(subject.instance_variable_get(:@triggers))
|
||||||
|
.to eq(@trigger_instance)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "as a base" do
|
describe "as a base" do
|
||||||
let(:base) { true}
|
let(:base) { true}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue