vagrant-proxmox 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sanity_checks.rb +1 -1
  3. data/lib/vagrant-proxmox.rb +1 -2
  4. data/lib/vagrant-proxmox/action.rb +133 -86
  5. data/lib/vagrant-proxmox/action/connect_proxmox.rb +10 -10
  6. data/lib/vagrant-proxmox/action/create_vm.rb +33 -28
  7. data/lib/vagrant-proxmox/action/destroy_vm.rb +10 -6
  8. data/lib/vagrant-proxmox/action/get_node_list.rb +8 -6
  9. data/lib/vagrant-proxmox/action/is_created.rb +1 -0
  10. data/lib/vagrant-proxmox/action/is_stopped.rb +1 -0
  11. data/lib/vagrant-proxmox/action/message_file_not_found.rb +21 -0
  12. data/lib/vagrant-proxmox/action/message_not_running.rb +20 -0
  13. data/lib/vagrant-proxmox/action/message_upload_server_error.rb +20 -0
  14. data/lib/vagrant-proxmox/action/proxmox_action.rb +6 -22
  15. data/lib/vagrant-proxmox/action/read_ssh_info.rb +1 -0
  16. data/lib/vagrant-proxmox/action/read_state.rb +11 -14
  17. data/lib/vagrant-proxmox/action/select_node.rb +23 -0
  18. data/lib/vagrant-proxmox/action/shutdown_vm.rb +8 -8
  19. data/lib/vagrant-proxmox/action/start_vm.rb +20 -12
  20. data/lib/vagrant-proxmox/action/stop_vm.rb +9 -8
  21. data/lib/vagrant-proxmox/action/sync_folders.rb +1 -1
  22. data/lib/vagrant-proxmox/action/upload_iso_file.rb +38 -0
  23. data/lib/vagrant-proxmox/action/upload_template_file.rb +38 -0
  24. data/lib/vagrant-proxmox/config.rb +85 -5
  25. data/lib/vagrant-proxmox/errors.rb +22 -2
  26. data/lib/vagrant-proxmox/plugin.rb +0 -14
  27. data/lib/vagrant-proxmox/proxmox/connection.rb +217 -0
  28. data/lib/vagrant-proxmox/proxmox/errors.rb +23 -0
  29. data/lib/vagrant-proxmox/version.rb +1 -1
  30. data/locales/en.yml +29 -2
  31. data/spec/actions/cleanup_after_destroy_action_spec.rb +2 -2
  32. data/spec/actions/connect_proxmox_action_spec.rb +32 -15
  33. data/spec/actions/create_vm_action_spec.rb +155 -130
  34. data/spec/actions/destroy_vm_action_spec.rb +50 -23
  35. data/spec/actions/get_node_list_action_spec.rb +25 -12
  36. data/spec/actions/is_created_action_spec.rb +8 -8
  37. data/spec/actions/is_stopped_action_spec.rb +8 -8
  38. data/spec/actions/message_already_running_action_spec.rb +2 -2
  39. data/spec/actions/message_already_stopped_action_spec.rb +2 -2
  40. data/spec/actions/message_file_not_found_spec.rb +23 -0
  41. data/spec/actions/message_not_created_action_spec.rb +2 -2
  42. data/spec/actions/message_not_running_action_spec.rb +23 -0
  43. data/spec/actions/message_upload_server_error_spec.rb +23 -0
  44. data/spec/actions/proxmox_action_shared.rb +0 -64
  45. data/spec/actions/proxmox_action_spec.rb +57 -0
  46. data/spec/actions/read_ssh_info_action_spec.rb +6 -6
  47. data/spec/actions/read_state_action_spec.rb +36 -34
  48. data/spec/actions/select_node_spec.rb +33 -0
  49. data/spec/actions/shutdown_vm_action_spec.rb +50 -22
  50. data/spec/actions/start_vm_action_spec.rb +87 -33
  51. data/spec/actions/stop_vm_action_spec.rb +50 -23
  52. data/spec/actions/sync_folders_action_spec.rb +9 -9
  53. data/spec/actions/upload_iso_file_action_spec.rb +70 -0
  54. data/spec/actions/upload_template_file_action_spec.rb +70 -0
  55. data/spec/commands/destroy_command_spec.rb +25 -25
  56. data/spec/commands/halt_command_spec.rb +17 -17
  57. data/spec/commands/provision_command_spec.rb +22 -9
  58. data/spec/commands/ssh_command_spec.rb +18 -5
  59. data/spec/commands/ssh_run_command_spec.rb +19 -6
  60. data/spec/commands/status_command_spec.rb +2 -2
  61. data/spec/commands/up_command_spec.rb +174 -34
  62. data/spec/config_spec.rb +325 -46
  63. data/spec/plugin_spec.rb +1 -8
  64. data/spec/provider_spec.rb +4 -4
  65. data/spec/proxmox/connection_spec.rb +662 -0
  66. data/spec/proxmox/rest_call_shared.rb +41 -0
  67. data/spec/sanity_checks_spec.rb +1 -1
  68. data/spec/spec_helper.rb +15 -97
  69. data/spec/spec_helpers/common_helpers.rb +111 -0
  70. data/spec/spec_helpers/time_helpers.rb +90 -0
  71. metadata +161 -45
@@ -1,37 +1,64 @@
1
1
  require 'spec_helper'
2
2
  require 'actions/proxmox_action_shared'
3
3
 
4
- describe VagrantPlugins::Proxmox::Action::DestroyVm do
4
+ module VagrantPlugins::Proxmox
5
5
 
6
- let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
- let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
8
- proxmox_nodes: [{node: 'localhost'}],
9
- ui: double('ui').as_null_object} }
6
+ describe Action::DestroyVm do
10
7
 
11
- subject { described_class.new(-> (_) {}, environment) }
8
+ let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
9
+ let(:connection) { Connection.new 'https://proxmox.example.com/api2/json' }
10
+ let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
11
+ ui: double('ui').as_null_object,
12
+ proxmox_connection: connection} }
12
13
 
13
- describe '#call' do
14
+ subject(:action) { described_class.new(-> (_) {}, environment) }
14
15
 
15
- before do
16
- env[:machine].id = 'localhost/100'
17
- allow(RestClient).to receive(:delete).and_return({data: 'task_id'}.to_json)
18
- allow(RestClient).to receive(:get).and_return({data: {exitstatus: 'OK'}}.to_json)
19
- end
16
+ describe '#call' do
20
17
 
21
- it_behaves_like 'a proxmox action call'
22
- it_behaves_like 'a blocking proxmox action'
18
+ before do
19
+ env[:machine].id = 'localhost/100'
20
+ allow(connection).to receive_messages :delete_vm => 'OK'
21
+ end
23
22
 
24
- it 'should send a post request that deletes the openvz container' do
25
- RestClient.should_receive(:delete).with('https://your.proxmox.server/api2/json/nodes/localhost/openvz/100', anything)
26
- subject.call env
27
- end
23
+ it_behaves_like 'a proxmox action call'
24
+
25
+ it 'should call the delete_vm function of connection' do
26
+ expect(connection).to receive(:delete_vm).with '100'
27
+ action.call env
28
+ end
29
+
30
+ it 'should print a message to the user interface' do
31
+ expect(env[:ui]).to receive(:info).with 'Destroying the virtual machine...'
32
+ expect(env[:ui]).to receive(:info).with 'Done!'
33
+ action.call env
34
+ end
35
+
36
+ context 'when the proxmox server responds with an error to the destroy request' do
37
+
38
+ context 'when the proxmox server replies with an internal server error to the destroy request' do
39
+ it 'should raise a VMDestroyError' do
40
+ allow(connection).to receive(:delete_vm).and_raise ApiError::ServerError
41
+ expect { action.send :call, env }.to raise_error Errors::VMDestroyError
42
+ end
43
+ end
44
+
45
+ context 'when the proxmox server replies with an internal server error to the task status request' do
46
+ it 'should raise a VMDestroyError' do
47
+ allow(connection).to receive(:delete_vm).and_raise ApiError::ServerError
48
+ expect { action.send :call, env }.to raise_error Errors::VMDestroyError
49
+ end
50
+ end
51
+
52
+ context 'when the proxmox server does not reply the task status request with OK' do
53
+ it 'should raise a VMDestroyError' do
54
+ allow(connection).to receive_messages :delete_vm => 'destroy vm error'
55
+ expect { action.send :call, env }.to raise_error Errors::VMDestroyError, /destroy vm error/
56
+ end
57
+ end
58
+
59
+ end
28
60
 
29
- it 'should print a message to the user interface' do
30
- env[:ui].should_receive(:info).with 'Destroying the virtual machine...'
31
- env[:ui].should_receive(:info).with 'Done!'
32
- subject.call env
33
61
  end
34
62
 
35
63
  end
36
-
37
64
  end
@@ -1,25 +1,38 @@
1
1
  require 'spec_helper'
2
2
  require 'actions/proxmox_action_shared'
3
3
 
4
- describe VagrantPlugins::Proxmox::Action::GetNodeList do
4
+ module VagrantPlugins::Proxmox
5
5
 
6
- let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
- let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox)} }
6
+ describe Action::GetNodeList do
8
7
 
9
- subject { described_class.new(-> (_) {}, environment) }
8
+ let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
9
+ let(:connection) { Connection.new 'https://proxmox.example.com/api2/json' }
10
+ let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox), proxmox_connection: connection} }
10
11
 
11
- describe '#call' do
12
+ subject(:action) { described_class.new(-> (_) {}, environment) }
12
13
 
13
- before {allow(RestClient).to receive(:get).and_return({data: [{node: 'localhost'}]}.to_json)}
14
+ describe '#call' do
14
15
 
15
- it_behaves_like 'a proxmox action call'
16
+ describe 'proxmox action call' do
17
+ before { allow(connection).to receive_messages get_node_list: [] }
18
+ it_behaves_like 'a proxmox action call'
19
+ end
20
+
21
+ it 'should store the node list in env[:proxmox_nodes]' do
22
+ expect(connection).to receive(:get_node_list).and_return ['node1', 'node2']
23
+ action.call env
24
+ expect(env[:proxmox_nodes]).to eq(['node1', 'node2'])
25
+ end
26
+
27
+ context 'when the server communication fails' do
28
+ before { allow(connection).to receive(:get_node_list).and_raise ApiError::ConnectionError }
29
+ it 'should raise an error' do
30
+ expect { action.call env }.to raise_error Errors::CommunicationError
31
+ end
32
+ end
16
33
 
17
- it 'should store the node list in env[:proxmox_nodes]' do
18
- RestClient.should_receive(:get).with('https://your.proxmox.server/api2/json/nodes', anything)
19
- subject.call env
20
- env[:proxmox_nodes].should == [{node: 'localhost'}]
21
34
  end
22
35
 
23
36
  end
24
37
 
25
- end
38
+ end
@@ -6,28 +6,28 @@ describe VagrantPlugins::Proxmox::Action::IsCreated do
6
6
  let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
7
  let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox)} }
8
8
 
9
- subject { described_class.new(-> (_) {}, environment) }
9
+ subject(:action) { described_class.new(-> (_) {}, environment) }
10
10
 
11
11
  describe '#call' do
12
12
 
13
- before{allow(env[:machine].provider).to receive(:state).and_return(Vagrant::MachineState.new nil, nil, nil)}
13
+ before { allow(env[:machine].provider).to receive_messages :state => Vagrant::MachineState.new(nil, nil, nil) }
14
14
 
15
15
  it_behaves_like 'a proxmox action call'
16
16
 
17
17
  context 'when the machine is stopped' do
18
18
  before do
19
- allow(env[:machine].provider).to receive(:state).and_return(Vagrant::MachineState.new :stopped, '', '')
20
- subject.call env
19
+ allow(env[:machine].provider).to receive_messages :state => Vagrant::MachineState.new(:stopped, '', '')
20
+ action.call env
21
21
  end
22
- specify { env[:result].should == true }
22
+ specify { expect(env[:result]).to eq(true) }
23
23
  end
24
24
 
25
25
  context 'when the machine is not created' do
26
26
  before do
27
- allow(env[:machine].provider).to receive(:state).and_return(Vagrant::MachineState.new :not_created, '', '')
28
- subject.call env
27
+ allow(env[:machine].provider).to receive_messages :state => Vagrant::MachineState.new(:not_created, '', '')
28
+ action.call env
29
29
  end
30
- specify { env[:result].should == false }
30
+ specify { expect(env[:result]).to eq(false) }
31
31
  end
32
32
 
33
33
  end
@@ -6,28 +6,28 @@ describe VagrantPlugins::Proxmox::Action::IsStopped do
6
6
  let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
7
  let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox)} }
8
8
 
9
- subject { described_class.new(-> (_) {}, environment) }
9
+ subject(:action) { described_class.new(-> (_) {}, environment) }
10
10
 
11
11
  describe '#call' do
12
12
 
13
- before { allow(env[:machine].provider).to receive(:state).and_return(Vagrant::MachineState.new nil, nil, nil) }
13
+ before { allow(env[:machine].provider).to receive_messages :state => Vagrant::MachineState.new(nil, nil, nil) }
14
14
 
15
15
  it_behaves_like 'a proxmox action call'
16
16
 
17
17
  context 'when the machine is stopped' do
18
18
  before do
19
- allow(env[:machine].provider).to receive(:state).and_return(Vagrant::MachineState.new :stopped, '', '')
20
- subject.call env
19
+ allow(env[:machine].provider).to receive_messages :state => Vagrant::MachineState.new(:stopped, '', '')
20
+ action.call env
21
21
  end
22
- specify { env[:result].should == true }
22
+ specify { expect(env[:result]).to eq(true) }
23
23
  end
24
24
 
25
25
  context 'when the machine is running' do
26
26
  before do
27
- allow(env[:machine].provider).to receive(:state).and_return(Vagrant::MachineState.new :running, '', '')
28
- subject.call env
27
+ allow(env[:machine].provider).to receive_messages :state => Vagrant::MachineState.new(:running, '', '')
28
+ action.call env
29
29
  end
30
- specify { env[:result].should == false }
30
+ specify { expect(env[:result]).to eq(false) }
31
31
  end
32
32
  end
33
33
 
@@ -6,7 +6,7 @@ describe VagrantPlugins::Proxmox::Action::MessageAlreadyRunning do
6
6
  let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
7
  let(:env) { {ui: double('ui').as_null_object} }
8
8
 
9
- subject { described_class.new(-> (_) {}, environment) }
9
+ subject(:action) { described_class.new(-> (_) {}, environment) }
10
10
 
11
11
  before { VagrantPlugins::Proxmox::Plugin.setup_i18n }
12
12
 
@@ -16,7 +16,7 @@ describe VagrantPlugins::Proxmox::Action::MessageAlreadyRunning do
16
16
 
17
17
  specify do
18
18
  expect(env[:ui]).to receive(:info).with 'The virtual machine is already up and running'
19
- subject.call env
19
+ action.call env
20
20
  end
21
21
  end
22
22
 
@@ -6,7 +6,7 @@ describe VagrantPlugins::Proxmox::Action::MessageAlreadyStopped do
6
6
  let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
7
  let(:env) { {ui: double('ui').as_null_object} }
8
8
 
9
- subject { described_class.new(-> (_) {}, environment) }
9
+ subject(:action) { described_class.new(-> (_) {}, environment) }
10
10
 
11
11
  before { VagrantPlugins::Proxmox::Plugin.setup_i18n }
12
12
 
@@ -16,7 +16,7 @@ describe VagrantPlugins::Proxmox::Action::MessageAlreadyStopped do
16
16
 
17
17
  specify do
18
18
  expect(env[:ui]).to receive(:info).with 'The virtual machine is already stopped'
19
- subject.call env
19
+ action.call env
20
20
  end
21
21
  end
22
22
 
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'actions/proxmox_action_shared'
3
+
4
+ describe VagrantPlugins::Proxmox::Action::MessageFileNotFound do
5
+
6
+ let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
+ let(:env) { {ui: double('ui').as_null_object} }
8
+
9
+ subject(:action) { described_class.new(-> (_) {}, environment) }
10
+
11
+ before { VagrantPlugins::Proxmox::Plugin.setup_i18n }
12
+
13
+ describe '#call' do
14
+
15
+ it_behaves_like 'a proxmox action call'
16
+
17
+ specify do
18
+ expect(env[:ui]).to receive(:info).with /File for upload not found/
19
+ action.call env
20
+ end
21
+ end
22
+
23
+ end
@@ -6,7 +6,7 @@ describe VagrantPlugins::Proxmox::Action::MessageNotCreated do
6
6
  let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
7
  let(:env) { {ui: double('ui').as_null_object} }
8
8
 
9
- subject { described_class.new(-> (_) {}, environment) }
9
+ subject(:action) { described_class.new(-> (_) {}, environment) }
10
10
 
11
11
  before { VagrantPlugins::Proxmox::Plugin.setup_i18n }
12
12
 
@@ -16,7 +16,7 @@ describe VagrantPlugins::Proxmox::Action::MessageNotCreated do
16
16
 
17
17
  specify do
18
18
  expect(env[:ui]).to receive(:info).with 'The virtual machine is not created on the server!'
19
- subject.call env
19
+ action.call env
20
20
  end
21
21
  end
22
22
 
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'actions/proxmox_action_shared'
3
+
4
+ describe VagrantPlugins::Proxmox::Action::MessageNotRunning do
5
+
6
+ let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
+ let(:env) { {ui: double('ui').as_null_object} }
8
+
9
+ subject(:action) { described_class.new(-> (_) {}, environment) }
10
+
11
+ before { VagrantPlugins::Proxmox::Plugin.setup_i18n }
12
+
13
+ describe '#call' do
14
+
15
+ it_behaves_like 'a proxmox action call'
16
+
17
+ specify do
18
+ expect(env[:ui]).to receive(:info).with /VM must be running to execute this command/
19
+ action.call env
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'actions/proxmox_action_shared'
3
+
4
+ describe VagrantPlugins::Proxmox::Action::MessageUploadServerError do
5
+
6
+ let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
+ let(:env) { {ui: double('ui').as_null_object} }
8
+
9
+ subject(:action) { described_class.new(-> (_) {}, environment) }
10
+
11
+ before { VagrantPlugins::Proxmox::Plugin.setup_i18n }
12
+
13
+ describe '#call' do
14
+
15
+ it_behaves_like 'a proxmox action call'
16
+
17
+ specify do
18
+ expect(env[:ui]).to receive(:info).with /Error during upload/
19
+ action.call env
20
+ end
21
+ end
22
+
23
+ end
@@ -1,58 +1,3 @@
1
- shared_examples VagrantPlugins::Proxmox::Action::ProxmoxAction do
2
-
3
- let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile'}
4
- let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
5
- proxmox_nodes: [{node: 'localhost'}]} }
6
- let(:task_upid) { 'UPID:localhost:0000F6ED:00F8E25F:5268CD3B:vzcreate:100:vagrant@pve:' }
7
-
8
- describe '#wait_for_completion' do
9
-
10
- context 'when the task is completed' do
11
- before { allow(subject).to receive(:get_task_exitstatus).and_return('OK') }
12
- it 'should return the tasks exit status' do
13
- subject.send(:wait_for_completion, task_upid, 'localhost', env, '').should == 'OK'
14
- end
15
- end
16
-
17
- context 'when the task times out' do
18
- before do
19
- allow(subject).to receive(:get_task_exitstatus).and_return(nil)
20
- Retryable.disable
21
- end
22
- it 'should raise an timeout error' do
23
- expect { subject.send(:wait_for_completion, task_upid, 'localhost', env, '') }.to raise_error VagrantPlugins::Proxmox::Errors::Timeout
24
- end
25
- after { Retryable.enable }
26
- end
27
-
28
- end
29
-
30
- describe '#get_task_exitstatus' do
31
-
32
- it 'should request the task state from the proxmox server' do
33
- RestClient.should_receive(:get).with("https://your.proxmox.server/api2/json/nodes/localhost/tasks/#{task_upid}/status", anything).
34
- and_return({data: {}}.to_json)
35
- subject.send(:get_task_exitstatus, task_upid, 'localhost', env)
36
- end
37
-
38
- context 'the task has exited' do
39
- it 'should return the exit status' do
40
- allow(RestClient).to receive(:get).and_return({data: {upid: task_upid, status: 'stopped', exitstatus: 'OK'}}.to_json)
41
- subject.send(:get_task_exitstatus, task_upid, 'localhost', env).should == 'OK'
42
- end
43
- end
44
-
45
- context 'the task is still running' do
46
- it 'should return nil' do
47
- allow(RestClient).to receive(:get).and_return({data: {upid: task_upid, status: 'running'}}.to_json)
48
- subject.send(:get_task_exitstatus, task_upid, 'localhost', env).should == nil
49
- end
50
- end
51
-
52
- end
53
-
54
- end
55
-
56
1
  shared_examples 'a proxmox action call' do
57
2
 
58
3
  describe 'when done' do
@@ -63,12 +8,3 @@ shared_examples 'a proxmox action call' do
63
8
  end
64
9
 
65
10
  end
66
-
67
- shared_examples 'a blocking proxmox action' do
68
-
69
- it 'waits for completion of the server task' do
70
- subject.should receive(:wait_for_completion)
71
- subject.call env
72
- end
73
-
74
- end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ module VagrantPlugins::Proxmox
4
+
5
+ describe Action::ProxmoxAction do
6
+
7
+ let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
8
+ let(:connection) { Connection.new 'https://proxmox.example.com/api2/json' }
9
+ let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
10
+ proxmox_connection: connection} }
11
+
12
+ let (:action) { subject }
13
+
14
+ describe '#next_action' do
15
+
16
+ let(:app) { double('app') }
17
+ before { action.instance_variable_set(:@app, app) }
18
+
19
+ it 'should call @app' do
20
+ expect(app).to receive(:call)
21
+ action.send(:next_action, env)
22
+ end
23
+ end
24
+
25
+ describe '#get_machine_ip_address' do
26
+
27
+ before do
28
+ allow(env[:machine].config.vm).to receive_messages networks: [[:private_network, {ip: '4.3.2.1'}], [:public_network, {ip: '1.2.3.4'}]]
29
+ end
30
+
31
+ it 'should return the first public ip address from the configuration' do
32
+ expect(action.send(:get_machine_ip_address, env)).to eq('1.2.3.4')
33
+ end
34
+
35
+ context 'no network configuration exists' do
36
+
37
+ before do
38
+ allow(env[:machine].config.vm).to receive_messages networks: nil
39
+ end
40
+
41
+ it 'should return nil' do
42
+ expect(action.send(:get_machine_ip_address, env)).to be_nil
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
49
+ describe '#connection' do
50
+ it 'should retrieve the connection from the environment' do
51
+ expect(action.send(:connection, env)).to eq(connection)
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+ end