From cf74347980543ca8a6249ad154c237ee2f2b1e59 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 5 Jun 2016 14:02:01 -0400 Subject: [PATCH] guests/freebsd: Install rsync in one command --- plugins/guests/freebsd/cap/rsync.rb | 9 +--- .../plugins/guests/freebsd/cap/rsync_test.rb | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 test/unit/plugins/guests/freebsd/cap/rsync_test.rb diff --git a/plugins/guests/freebsd/cap/rsync.rb b/plugins/guests/freebsd/cap/rsync.rb index fde6ed620..5bcffc347 100644 --- a/plugins/guests/freebsd/cap/rsync.rb +++ b/plugins/guests/freebsd/cap/rsync.rb @@ -3,14 +3,7 @@ module VagrantPlugins module Cap class RSync def self.rsync_install(machine) - version = nil - machine.communicate.execute("uname -r") do |type, result| - version = result.split('.')[0].to_i if type == :stdout - end - - pkg_cmd = "pkg install -y" - - machine.communicate.sudo("#{pkg_cmd} rsync") + machine.communicate.sudo("pkg install -y rsync") end def self.rsync_installed(machine) diff --git a/test/unit/plugins/guests/freebsd/cap/rsync_test.rb b/test/unit/plugins/guests/freebsd/cap/rsync_test.rb new file mode 100644 index 000000000..d0ad41829 --- /dev/null +++ b/test/unit/plugins/guests/freebsd/cap/rsync_test.rb @@ -0,0 +1,46 @@ +require_relative "../../../../base" + +describe "VagrantPlugins::GuestFreeBSD::Cap::RSync" do + let(:caps) do + VagrantPlugins::GuestFreeBSD::Plugin + .components + .guest_capabilities[:freebsd] + end + + let(:machine) { double("machine") } + let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) } + + before do + allow(machine).to receive(:communicate).and_return(comm) + end + + after do + comm.verify_expectations! + end + + describe ".rsync_install" do + let(:cap) { caps.get(:rsync_install) } + + it "installs rsync" do + comm.expect_command("pkg install -y rsync") + cap.rsync_install(machine) + end + end + + describe ".rsync_installed" do + let(:cap) { caps.get(:rsync_installed) } + + it "checks if rsync is installed" do + comm.expect_command("which rsync") + cap.rsync_installed(machine) + end + end + + describe ".rsync_command" do + let(:cap) { caps.get(:rsync_command) } + + it "defaults to 'sudo rsync'" do + expect(cap.rsync_command(machine)).to eq("sudo rsync") + end + end +end