Tests regarding warning whenever CWD changes
This commit is contained in:
parent
15871a481b
commit
48b0e00368
|
@ -170,7 +170,7 @@ module Vagrant
|
|||
# Extra env keys are the remaining opts
|
||||
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
|
||||
vf = nil
|
||||
|
|
|
@ -307,6 +307,28 @@ describe Vagrant::Machine do
|
|||
expect { instance.action(action_name) }.
|
||||
to raise_error(Vagrant::Errors::UnimplementedProviderAction)
|
||||
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
|
||||
|
||||
describe "#action_raw" do
|
||||
|
|
Loading…
Reference in New Issue