Tests regarding warning whenever CWD changes

This commit is contained in:
Fernando Seror 2017-04-18 18:45:20 -05:00 committed by Brian Cain
parent 15871a481b
commit 48b0e00368
2 changed files with 23 additions and 1 deletions

View File

@ -170,7 +170,7 @@ module Vagrant
# Extra env keys are the remaining opts # Extra env keys are the remaining opts
extra_env = opts.dup extra_env = opts.dup
check_cwd check_cwd # Warns the UI if the machine was last used on a different dir
# Create a deterministic ID for this machine # Create a deterministic ID for this machine
vf = nil vf = nil

View File

@ -307,6 +307,28 @@ describe Vagrant::Machine do
expect { instance.action(action_name) }. expect { instance.action(action_name) }.
to raise_error(Vagrant::Errors::UnimplementedProviderAction) to raise_error(Vagrant::Errors::UnimplementedProviderAction)
end end
it 'should warn if the machine was last run under a different directory' do
action_name = :up
callable = lambda { |_env| }
original_cwd = env.cwd.to_s
allow(provider).to receive(:action).with(action_name).and_return(callable)
allow(subject.ui).to receive(:warn)
instance.action(action_name)
expect(subject.ui).to_not have_received(:warn)
# Whenever the machine is run on a different directory, the user is warned
allow(env).to receive(:cwd).and_return('/a/new/path')
instance.action(action_name)
expect(subject.ui).to have_received(:warn) do |warn_msg|
expect(warn_msg).to include(original_cwd)
expect(warn_msg).to include('/a/new/path')
end
end
end end
describe "#action_raw" do describe "#action_raw" do