guests/freebsd: Install rsync in one command

This commit is contained in:
Seth Vargo 2016-06-05 14:02:01 -04:00
parent de64bd03de
commit cf74347980
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
2 changed files with 47 additions and 8 deletions

View File

@ -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)

View File

@ -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