From 8bf93eb6f97555b60fcb71a04846e5e8f142d56c Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Mon, 31 Jul 2017 10:18:47 +0200 Subject: [PATCH 1/9] Update chagelog --- CHANGELOG.md | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 819fec03..68a52674 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,22 @@ +## 1.7.6 (July 31, 2017) +BUG FIXES: + - Fixed `vagrant up` failure if the box image was automatically renamed due + to the name conflict. + [[GH-303](https://github.com/Parallels/vagrant-parallels/issues/303)] + ## 1.7.5 (May 27, 2017) BUG FIXES: - - Fixed compatibility with Vagrant v1.9.5+. `nokogiri` gem is defined as - a plugin runtime dependency. - [[GH-297](https://github.com/Parallels/vagrant-parallels/issues/297)], - [[GH-298](https://github.com/Parallels/vagrant-parallels/pull/298)] - - **NB!** To use the plugin with Vagrant v1.9.5 you should (re)install it with - `NOKOGIRI_USE_SYSTEM_LIBRARIES` enabled: - ```bash - $ vagrant plugin uninstall vagrant-parallels - $ NOKOGIRI_USE_SYSTEM_LIBRARIES=true vagrant plugin install vagrant-parallels - ``` + - Fixed compatibility with Vagrant v1.9.5+. `nokogiri` gem is defined as + a plugin runtime dependency. + [[GH-297](https://github.com/Parallels/vagrant-parallels/issues/297)], + [[GH-298](https://github.com/Parallels/vagrant-parallels/pull/298)] + + **NB!** To use the plugin with Vagrant v1.9.5 you should (re)install it with + `NOKOGIRI_USE_SYSTEM_LIBRARIES` enabled: + ```bash + $ vagrant plugin uninstall vagrant-parallels + $ NOKOGIRI_USE_SYSTEM_LIBRARIES=true vagrant plugin install vagrant-parallels + ``` ## 1.7.4 (April 20, 2017) From 635150d2ee2233183a75b324afc69581ba8a32a1 Mon Sep 17 00:00:00 2001 From: Roman Kulikov Date: Wed, 27 Sep 2017 15:25:32 +0300 Subject: [PATCH 2/9] gemspec: fix version of rspec dependency Need to bump up version to "~> 3.5.0" because vagrant-sepc requires such constraint. --- vagrant-parallels.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vagrant-parallels.gemspec b/vagrant-parallels.gemspec index 27aa5cf1..a6ebd9b8 100644 --- a/vagrant-parallels.gemspec +++ b/vagrant-parallels.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| # Constraint rake to properly handle deprecated method usage # from within rspec spec.add_development_dependency 'rake', '~> 11.3.0' - spec.add_development_dependency 'rspec', '~> 2.14.0' + spec.add_development_dependency 'rspec', '~> 3.5.0' spec.files = Dir['lib/**/*', 'locales/**/*', 'README.md', 'CHANGELOG.md', 'LICENSE.txt'] spec.require_path = 'lib' From ffbb4cc4aca22bf12e7d74226907e34298e09e83 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Sun, 1 Oct 2017 22:39:00 +0200 Subject: [PATCH 3/9] test/unit: Fix compatibility with RSpec 3.2+ --- test/unit/base.rb | 2 +- test/unit/support/shared/pd_driver_examples.rb | 4 ++-- test/unit/synced_folder_test.rb | 4 +--- vagrant-parallels.gemspec | 1 + 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/test/unit/base.rb b/test/unit/base.rb index 67b62e6d..666b371e 100644 --- a/test/unit/base.rb +++ b/test/unit/base.rb @@ -1,5 +1,5 @@ require 'rubygems' -require 'rspec/autorun' +require 'rspec/its' # Require Vagrant itself so we can reference the proper # classes to test. diff --git a/test/unit/support/shared/pd_driver_examples.rb b/test/unit/support/shared/pd_driver_examples.rb index a518a3e5..36ef7a56 100644 --- a/test/unit/support/shared/pd_driver_examples.rb +++ b/test/unit/support/shared/pd_driver_examples.rb @@ -225,7 +225,7 @@ describe 'read_vms' do it 'returns the list of all registered VMs and templates' do subject.read_vms.should be_kind_of(Hash) - subject.read_vms.should have_at_least(2).items + expect(subject.read_vms.keys.length).to be >= 2 subject.read_vms.should include(vm_name => uuid) end end @@ -233,7 +233,7 @@ describe 'read_vms_info' do it 'returns detailed info about all registered VMs and templates' do subject.read_vms_info.should be_kind_of(Array) - subject.read_vms_info.should have_at_least(2).items + expect(subject.read_vms.keys.length).to be >= 2 # It should include info about current VM vm_settings = driver.send(:read_settings) diff --git a/test/unit/synced_folder_test.rb b/test/unit/synced_folder_test.rb index bbfa8d7d..359dbfd3 100644 --- a/test/unit/synced_folder_test.rb +++ b/test/unit/synced_folder_test.rb @@ -42,8 +42,6 @@ machine.stub(driver: driver) end - it 'should share the folders' do - pending - end + it 'should share the folders' end end diff --git a/vagrant-parallels.gemspec b/vagrant-parallels.gemspec index a6ebd9b8..85b8975c 100644 --- a/vagrant-parallels.gemspec +++ b/vagrant-parallels.gemspec @@ -22,6 +22,7 @@ Gem::Specification.new do |spec| # from within rspec spec.add_development_dependency 'rake', '~> 11.3.0' spec.add_development_dependency 'rspec', '~> 3.5.0' + spec.add_development_dependency 'rspec-its', '~> 1.2.0' spec.files = Dir['lib/**/*', 'locales/**/*', 'README.md', 'CHANGELOG.md', 'LICENSE.txt'] spec.require_path = 'lib' From 8a188d0bdba5cb24cbe86cc72326cf00c563e71b Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Sun, 1 Oct 2017 22:43:09 +0200 Subject: [PATCH 4/9] test/unit: Convert "should" to "expect" --- test/unit/action/network_test.rb | 2 +- test/unit/cap_test.rb | 4 +- test/unit/config_test.rb | 6 +- test/unit/driver/pd_10_test.rb | 4 +- test/unit/support/shared/parallels_context.rb | 18 +-- .../unit/support/shared/pd_driver_examples.rb | 112 +++++++++--------- test/unit/synced_folder_test.rb | 14 +-- 7 files changed, 80 insertions(+), 80 deletions(-) diff --git a/test/unit/action/network_test.rb b/test/unit/action/network_test.rb index 4a50b7b0..7db47c58 100644 --- a/test/unit/action/network_test.rb +++ b/test/unit/action/network_test.rb @@ -15,7 +15,7 @@ let(:machine) do iso_env.machine(iso_env.machine_names[0], :parallels).tap do |m| - m.provider.stub(driver: driver) + allow(m.provider).to receive_messages(driver: driver) end end diff --git a/test/unit/cap_test.rb b/test/unit/cap_test.rb index 6d10be5c..58a5b0ec 100644 --- a/test/unit/cap_test.rb +++ b/test/unit/cap_test.rb @@ -14,8 +14,8 @@ let(:machine) do iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m| - m.provider.stub(driver: driver) - m.stub(state: state) + allow(m.provider).to receive_messages(driver: driver) + allow(m).to receive_messages(state: state) end end diff --git a/test/unit/config_test.rb b/test/unit/config_test.rb index ab62884e..2745b4be 100644 --- a/test/unit/config_test.rb +++ b/test/unit/config_test.rb @@ -21,10 +21,10 @@ def assert_valid before do vm_config = double('vm_config') - vm_config.stub(networks: []) + allow(vm_config).to receive_messages(networks: []) config = double('config') - config.stub(vm: vm_config) - machine.stub(config: config) + allow(config).to receive_messages(vm: vm_config) + allow(machine).to receive_messages(config: config) end its 'valid by default' do diff --git a/test/unit/driver/pd_10_test.rb b/test/unit/driver/pd_10_test.rb index e4118b16..1d752b9d 100644 --- a/test/unit/driver/pd_10_test.rb +++ b/test/unit/driver/pd_10_test.rb @@ -10,7 +10,7 @@ describe 'set_power_consumption_mode' do it "turns 'longer-battery-life' on" do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'set', uuid, '--longer-battery-life', 'on', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -19,7 +19,7 @@ end it "turns 'longer-battery-life' off" do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'set', uuid, '--longer-battery-life', 'off', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) diff --git a/test/unit/support/shared/parallels_context.rb b/test/unit/support/shared/parallels_context.rb index 0e66ebeb..3e5d3190 100644 --- a/test/unit/support/shared/parallels_context.rb +++ b/test/unit/support/shared/parallels_context.rb @@ -45,24 +45,24 @@ def subprocess_result(options={}) # drivers will blow up on instantiation if they cannot determine the # Parallels Desktop version, so wire this stub in automatically - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('prlctl', '--version', an_instance_of(Hash)). and_return(subprocess_result(stdout: "prlctl version #{parallels_version}.0.0 (12345)")) # drivers will sould chek the Parallels Desktop edition, so wire this stub in automatically - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('prlsrvctl', 'info', '--license', '--json', an_instance_of(Hash)). and_return(subprocess_result(stdout: '{"edition": "pro"}')) # drivers also call vm_exists? during init; - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('prlctl', 'list', uuid, kind_of(Hash)). and_return(subprocess_result(exit_code: 0)) # Returns detailed info about specified VM or all registered VMs # `prlctl list --info --no-header --json` # `prlctl list --all --info --no-header --json` - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('prlctl', 'list', kind_of(String), '--info', '--no-header', '--json', kind_of(Hash)) do out = <<-eos @@ -123,7 +123,7 @@ def subprocess_result(options={}) # Returns detailed info about specified template or all registered templates # `prlctl list --info --json --no-header --template` # `prlctl list --all --info --no-header --json --template` - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('prlctl', 'list', kind_of(String), '--info', '--no-header', '--json', '--template', kind_of(Hash)) do out = <<-eos @@ -172,7 +172,7 @@ def subprocess_result(options={}) # Returns detailed info about virtual network interface # `prlsrvctl net info , '--json'` - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('prlsrvctl', 'net', 'info', kind_of(String), '--json', kind_of(Hash)) do out = <<-eos @@ -196,7 +196,7 @@ def subprocess_result(options={}) # Returns values of 'name' and 'uuid' options for all registered VMs # `prlctl list --all --no-header --json -o name,uuid` - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('prlctl', 'list', '--all', '--no-header', '--json', '-o', 'name,uuid', kind_of(Hash)) do out = <<-eos @@ -212,7 +212,7 @@ def subprocess_result(options={}) # Returns values of 'name' and 'uuid' options for all registered templates # `prlctl list --all --no-header --json -o name,uuid --template` - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('prlctl', 'list', '--all', '--no-header', '--json', '-o', 'name,uuid', '--template', kind_of(Hash)) do out = <<-eos @@ -228,7 +228,7 @@ def subprocess_result(options={}) # Returns value of 'mac' options for the specified VM # `prlctl list --all --no-header -o mac` - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('prlctl', 'list', kind_of(String), '--no-header', '-o', 'mac', kind_of(Hash)) do subprocess_result(stdout: "00:1C:42:B4:B0:74 00:1C:42:B4:B0:90\n") diff --git a/test/unit/support/shared/pd_driver_examples.rb b/test/unit/support/shared/pd_driver_examples.rb index 36ef7a56..ad3a3165 100644 --- a/test/unit/support/shared/pd_driver_examples.rb +++ b/test/unit/support/shared/pd_driver_examples.rb @@ -5,7 +5,7 @@ describe 'compact_hdd' do it 'compacts the virtual disk' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prl_disk_tool', 'compact', '--hdd', '/foo.hdd', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -15,7 +15,7 @@ describe 'clear_shared_folders' do it 'deletes every shared folder assigned to the VM' do - subprocess.should_receive(:execute).at_least(2).times. + expect(subprocess).to receive(:execute).at_least(2).times. with('prlctl', 'set', uuid, '--shf-host-del', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -37,12 +37,12 @@ } } - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlsrvctl', 'net', 'add', vnic_opts[:network_id], '--type', 'host-only', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlsrvctl', 'net', 'set', vnic_opts[:network_id], '--ip', "#{vnic_opts[:adapter_ip]}/#{vnic_opts[:netmask]}", '--dhcp-ip', vnic_opts[:dhcp][:ip], @@ -52,9 +52,9 @@ interface = subject.create_host_only_network(vnic_opts) - interface.should include(:ip => vnic_opts[:adapter_ip]) - interface.should include(:netmask => vnic_opts[:netmask]) - interface.should include(:dhcp => vnic_opts[:dhcp]) + expect(interface).to include(:ip => vnic_opts[:adapter_ip]) + expect(interface).to include(:netmask => vnic_opts[:netmask]) + expect(interface).to include(:dhcp => vnic_opts[:dhcp]) # TODO: implement nicer tests for all supported PD versions # interface.should include(:name => hostonly_iface) # interface[:name].should =~ /^(vnic(\d+))$/ @@ -67,12 +67,12 @@ netmask: '255.255.254.0', } - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlsrvctl', 'net', 'add', vnic_options[:network_id], '--type', 'host-only', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlsrvctl', 'net', 'set', vnic_options[:network_id], '--ip', "#{vnic_options[:adapter_ip]}/#{vnic_options[:netmask]}", an_instance_of(Hash)). @@ -80,9 +80,9 @@ interface = subject.create_host_only_network(vnic_options) - interface.should include(:ip => vnic_options[:adapter_ip]) - interface.should include(:netmask => vnic_options[:netmask]) - interface.should include(:dhcp => nil) + expect(interface).to include(:ip => vnic_options[:adapter_ip]) + expect(interface).to include(:netmask => vnic_options[:netmask]) + expect(interface).to include(:dhcp => nil) # TODO: implement nicer tests for all supported PD versions # interface.should include(:name => hostonly_iface) # interface[:name].should =~ /^(vnic(\d+))$/ @@ -91,7 +91,7 @@ describe 'delete' do it 'deletes the VM' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'delete', uuid, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.delete @@ -102,8 +102,8 @@ it 'deletes disabled networks adapters from VM config' do settings = {'Hardware' => {'net0' => {'enabled' => false}, 'net1' => {'enabled' => false}}} - driver.should_receive(:read_settings).and_return(settings) - subprocess.should_receive(:execute).exactly(2).times. + expect(driver).to receive(:read_settings).and_return(settings) + expect(subprocess).to receive(:execute).exactly(2).times. with('prlctl', 'set', uuid, '--device-del', /^net(0|1)$/, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -113,7 +113,7 @@ describe 'clone_vm' do it 'clones VM to the new one' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'clone', tpl_uuid, '--name', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -121,7 +121,7 @@ end it 'clones VM to the exported VM' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'clone', uuid, '--name', an_instance_of(String), '--dst', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -131,14 +131,14 @@ describe 'halt' do it 'stops the VM' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'stop', uuid, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.halt end it 'stops the VM force' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'stop', uuid, '--kill', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.halt(force=true) @@ -149,70 +149,70 @@ let(:tools_state) {'outdated'} it 'returns Guest Tools state as a symbol' do - subject.read_guest_tools_state.should be(:outdated) + expect(subject.read_guest_tools_state).to be(:outdated) end it "returns :not_installed if Guest Tools state can't be reached" do - driver.should_receive(:read_settings).and_return(exit_code: 0) - subject.read_guest_tools_state.should be(:not_installed) + expect(driver).to receive(:read_settings).and_return(exit_code: 0) + expect(subject.read_guest_tools_state).to be(:not_installed) end end describe 'read_guest_tools_iso_path' do before do - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('mdfind', /^kMDItemCFBundleIdentifier ==/, an_instance_of(Hash)). and_return(subprocess_result(stdout: '/Applications/Parallels Desktop.app')) end it 'returns a valid path to the ISO' do - File.stub(:exist?).and_return(true) + allow(File).to receive(:exist?).and_return(true) iso_path = subject.read_guest_tools_iso_path('linux') - iso_path.should be_kind_of(String) - iso_path.should match(/prl-tools-lin\.iso$/) + expect(iso_path).to be_kind_of(String) + expect(iso_path).to match(/prl-tools-lin\.iso$/) end it 'raises an exception if ISO file does not exists' do - File.stub(:exist?).and_return(false) + allow(File).to receive(:exist?).and_return(false) expect { subject.read_guest_tools_iso_path('windows') }. to raise_error(VagrantPlugins::Parallels::Errors::ParallelsToolsIsoNotFound) end it 'returns nil if guest OS is unsupported or invalid' do - subject.read_guest_tools_iso_path('').should be_nil - subject.read_guest_tools_iso_path('bolgenos').should be_nil + expect(subject.read_guest_tools_iso_path('')).to be_nil + expect(subject.read_guest_tools_iso_path('bolgenos')).to be_nil end end describe 'read_mac_addresses' do it 'returns MAC addresses of all network interface cards' do - subject.read_mac_addresses.should be_kind_of(Array) - subject.read_mac_addresses.should include('001C42B4B074') - subject.read_mac_addresses.should include('001C42B4B090') + expect(subject.read_mac_addresses).to be_kind_of(Array) + expect(subject.read_mac_addresses).to include('001C42B4B074') + expect(subject.read_mac_addresses).to include('001C42B4B090') end end describe 'read_settings' do it 'returns a hash with detailed info about the VM' do - subject.read_settings.should be_kind_of(Hash) - subject.read_settings.should include('ID' => uuid) - subject.read_settings.should include('Hardware') - subject.read_settings.should include('GuestTools') + expect(subject.read_settings).to be_kind_of(Hash) + expect(subject.read_settings).to include('ID' => uuid) + expect(subject.read_settings).to include('Hardware') + expect(subject.read_settings).to include('GuestTools') end end describe 'read_vm_option' do it 'returns stripped value' do - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('prlctl', 'list', uuid, '--no-header', '-o', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(stdout: "opt_val \n")) - subject.read_vm_option('supported_option').should == 'opt_val' + expect(subject.read_vm_option('supported_option')).to eq('opt_val') end it 'raises an exception in option is not available' do - subprocess.stub(:execute). + allow(subprocess).to receive(:execute). with('prlctl', 'list', uuid, '--no-header', '-o', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(stdout: " \n")) @@ -224,26 +224,26 @@ describe 'read_vms' do it 'returns the list of all registered VMs and templates' do - subject.read_vms.should be_kind_of(Hash) + expect(subject.read_vms).to be_kind_of(Hash) expect(subject.read_vms.keys.length).to be >= 2 - subject.read_vms.should include(vm_name => uuid) + expect(subject.read_vms).to include(vm_name => uuid) end end describe 'read_vms_info' do it 'returns detailed info about all registered VMs and templates' do - subject.read_vms_info.should be_kind_of(Array) + expect(subject.read_vms_info).to be_kind_of(Array) expect(subject.read_vms.keys.length).to be >= 2 # It should include info about current VM vm_settings = driver.send(:read_settings) - subject.read_vms_info.should include(vm_settings) + expect(subject.read_vms_info).to include(vm_settings) end end describe 'register' do it 'registers specified virtual machine or template' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'register', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -253,7 +253,7 @@ describe 'set_name' do it 'sets new name for the VM' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'set', uuid, '--name', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -267,16 +267,16 @@ 10.200.0.99="1394547632,1800,001c420000ff,01001c420000ff"'} it 'returns an IP address assigned to the specified MAC' do - driver.should_receive(:read_mac_address).and_return('001C420000FF') - File.should_receive(:open).with(an_instance_of(String)). + expect(driver).to receive(:read_mac_address).and_return('001C420000FF') + expect(File).to receive(:open).with(an_instance_of(String)). and_return(StringIO.new(content)) - subject.ssh_ip.should == '10.200.0.99' + expect(subject.ssh_ip).to eq('10.200.0.99') end it 'rises DhcpLeasesNotAccessible exception when file is not accessible' do - File.stub(:open).and_call_original - File.should_receive(:open).with(an_instance_of(String)). + allow(File).to receive(:open).and_call_original + expect(File).to receive(:open).with(an_instance_of(String)). and_raise(Errno::EACCES) expect { subject.ssh_ip }. to raise_error(VagrantPlugins::Parallels::Errors::DhcpLeasesNotAccessible) @@ -285,7 +285,7 @@ describe 'start' do it 'starts the VM' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'start', uuid, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.start @@ -294,7 +294,7 @@ describe 'suspend' do it 'suspends the VM' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'suspend', uuid, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.suspend @@ -303,7 +303,7 @@ describe 'unregister' do it 'suspends the VM' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', 'unregister', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -313,11 +313,11 @@ describe 'version' do it 'parses the version from output' do - subject.version.should match(/^#{parallels_version}.\d+\.\d+$/) + expect(subject.version).to match(/^#{parallels_version}.\d+\.\d+$/) end it 'raises an exception for unsupported version' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', '--version', an_instance_of(Hash)). and_return(subprocess_result(stdout: 'prlctl version 7.0.12345')) expect { subject.version }. @@ -325,7 +325,7 @@ end it 'raises an exception for invalid version output' do - subprocess.should_receive(:execute). + expect(subprocess).to receive(:execute). with('prlctl', '--version', an_instance_of(Hash)). and_return(subprocess_result(stdout: 'prlctl version 1.2.foo.bar')) expect { subject.version }. diff --git a/test/unit/synced_folder_test.rb b/test/unit/synced_folder_test.rb index 359dbfd3..be752c11 100644 --- a/test/unit/synced_folder_test.rb +++ b/test/unit/synced_folder_test.rb @@ -7,8 +7,8 @@ describe VagrantPlugins::Parallels::SyncedFolder do let(:machine) do double('machine').tap do |m| - m.stub(provider_config: VagrantPlugins::Parallels::Config.new) - m.stub(provider_name: :parallels) + allow(m).to receive_messages(provider_config: VagrantPlugins::Parallels::Config.new) + allow(m).to receive_messages(provider_name: :parallels) end end @@ -20,13 +20,13 @@ describe 'usable' do it 'should be with parallels provider' do - machine.stub(provider_name: :parallels) - subject.should be_usable(machine) + allow(machine).to receive_messages(provider_name: :parallels) + expect(subject).to be_usable(machine) end it 'should not be with another provider' do - machine.stub(provider_name: :virtualbox) - subject.should_not be_usable(machine) + allow(machine).to receive_messages(provider_name: :virtualbox) + expect(subject).not_to be_usable(machine) end it 'should not be usable if not functional psf' do @@ -39,7 +39,7 @@ let(:driver) { double('driver') } before do - machine.stub(driver: driver) + allow(machine).to receive_messages(driver: driver) end it 'should share the folders' From 3f40fc12f74e7d67b992e3b1e380774a6587324b Mon Sep 17 00:00:00 2001 From: Dmitry Volosnykh Date: Tue, 12 Sep 2017 01:32:08 +0300 Subject: [PATCH 5/9] Fix synced folder mounting on Ubuntu 16.04 --- .../guest_cap/linux/mount_parallels_shared_folder.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb b/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb index 482bb978..2e1ec0ae 100644 --- a/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb +++ b/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb @@ -80,10 +80,11 @@ def self.mount_parallels_shared_folder(machine, name, guestpath, options) end # Emit an upstart event if we can - if machine.communicate.test('test -x /sbin/initctl') - machine.communicate.sudo( - "/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{expanded_guest_path}") - end + machine.communicate.sudo <<-EOH.gsub(/^ {10}/, "") + if command -v /sbin/init && /sbin/init 2>/dev/null --version | grep upstart; then + /sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{expanded_guest_path} + fi + EOH end def self.unmount_parallels_shared_folder(machine, guestpath, options) From 9c01a3fd5de23887936df2752cdf2ec48e33b7ad Mon Sep 17 00:00:00 2001 From: Aleksandr Sursiakov Date: Fri, 6 Oct 2017 19:22:39 +0300 Subject: [PATCH 6/9] [doc] Explain Paralells Shared Folders settings when using Vagrant Addresses https://github.com/Parallels/vagrant-parallels/issues/306 --- .../docs/source/docs/configuration.html.md | 4 +++- .../docs/source/docs/sharedfolders.html.md | 19 +++++++++++++++++++ website/docs/source/layouts/layout.erb | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 website/docs/source/docs/sharedfolders.html.md diff --git a/website/docs/source/docs/configuration.html.md b/website/docs/source/docs/configuration.html.md index 2ab442cf..3c9992c0 100755 --- a/website/docs/source/docs/configuration.html.md +++ b/website/docs/source/docs/configuration.html.md @@ -88,6 +88,8 @@ end In this case the both of Parallels Tools status check and an automatic update procedure will be skipped as well. +
+ ## Customization with prlctl Parallels Desktop includes the `prlctl` command-line utility that can be used to @@ -122,4 +124,4 @@ end You can read the [Command-Line Reference](http://download.parallels.com/desktop/v11/docs/en_US/Parallels%20Desktop%20Pro%20Edition%20Command-Line%20Reference.pdf) -for the complete information about the prlctl command and its options. \ No newline at end of file +for the complete information about the prlctl command and its options. diff --git a/website/docs/source/docs/sharedfolders.html.md b/website/docs/source/docs/sharedfolders.html.md new file mode 100644 index 00000000..eae79972 --- /dev/null +++ b/website/docs/source/docs/sharedfolders.html.md @@ -0,0 +1,19 @@ +--- +page_title: "Shared Folders" +sidebar_current: "sharedfolders" +--- + +# Shared Folders + +By default, Vagrant will share your project directory (the directory with the Vagrantfile) to /vagrant. + +If you need to add other folders, then you can to specify them in a Vagrantfile this way: + +```ruby +config.vm.synced_folder "~/", "/media/psf/Home" +config.vm.synced_folder "/", "/media/psf/Mac_Root" +``` + +You might want to share folders by passing Parallels Command Line as described in [Customization with prlctl](/docs/configuration.html#prlctl), but it won't work. It is done to avoid conflicts and keep vagrant configs more platform agnostic. + +You can read more about syncing host and guest folders in the [Vagrant Documentation](https://www.vagrantup.com/docs/synced-folders/basic_usage.html). diff --git a/website/docs/source/layouts/layout.erb b/website/docs/source/layouts/layout.erb index 908d914d..f3ec29c8 100644 --- a/website/docs/source/layouts/layout.erb +++ b/website/docs/source/layouts/layout.erb @@ -78,6 +78,8 @@ <% end %> + ><%= link_to 'Shared Folders', '/docs/sharedfolders.html' %> + ><%= link_to 'Configuration', '/docs/configuration.html' %> ><%= link_to 'Networking', '/docs/networking/index.html' %> From f7dcd170dc2fc9ec416537bffd58d9f76aa4f977 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Fri, 6 Oct 2017 20:24:14 +0200 Subject: [PATCH 7/9] website: Fix indentation in layout sources --- website/docs/source/layouts/layout.erb | 190 ++++++++++++------------- 1 file changed, 93 insertions(+), 97 deletions(-) diff --git a/website/docs/source/layouts/layout.erb b/website/docs/source/layouts/layout.erb index f3ec29c8..2e5561f9 100644 --- a/website/docs/source/layouts/layout.erb +++ b/website/docs/source/layouts/layout.erb @@ -29,112 +29,108 @@
- - -
-
- - -
-
- <%= yield %> -
-
-
+ + +
+
+ + +
+
+ <%= yield %> +
+
+
From 30d725b2b82b98e50fafae85def0957332fed9ee Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Sun, 15 Oct 2017 13:46:49 +0200 Subject: [PATCH 8/9] Update Changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68a52674..6d2703c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,16 @@ +## 1.7.7 (October 15, 2017) +BUG FIXES: + - Fixed synced folder mounting on guests with Upstart (Ubuntu 14.*) + [[GH-307](https://github.com/Parallels/vagrant-parallels/issues/307)] + + ## 1.7.6 (July 31, 2017) BUG FIXES: - Fixed `vagrant up` failure if the box image was automatically renamed due to the name conflict. [[GH-303](https://github.com/Parallels/vagrant-parallels/issues/303)] + ## 1.7.5 (May 27, 2017) BUG FIXES: - Fixed compatibility with Vagrant v1.9.5+. `nokogiri` gem is defined as From 509b0c756f9a79ea17f38cdc4493f6c173d6059a Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Sun, 15 Oct 2017 13:47:45 +0200 Subject: [PATCH 9/9] Bump version to v1.7.7 --- lib/vagrant-parallels/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-parallels/version.rb b/lib/vagrant-parallels/version.rb index 66570535..ad8d0fe1 100644 --- a/lib/vagrant-parallels/version.rb +++ b/lib/vagrant-parallels/version.rb @@ -1,5 +1,5 @@ module VagrantPlugins module Parallels - VERSION = '1.7.6' + VERSION = '1.7.7' end end