guests/redhat: Install RedHat in one command

This commit is contained in:
Seth Vargo 2016-06-05 19:12:03 -04:00
parent 3098c13869
commit 60d2f4e1b4
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
2 changed files with 35 additions and 6 deletions

View File

@ -3,13 +3,13 @@ module VagrantPlugins
module Cap
class RSync
def self.rsync_install(machine)
machine.communicate.tap do |comm|
if VagrantPlugins::GuestRedHat::Plugin.dnf?(machine)
comm.sudo("dnf -y install rsync")
machine.communicate.sudo <<-EOH.gsub(/^ {12}/, '')
if command -v dnf; then
dnf -y install rsync
else
comm.sudo("yum -y install rsync")
end
end
yum -y install rsync
fi
EOH
end
end
end

View File

@ -0,0 +1,29 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestRedHat::Cap:RSync" do
let(:caps) do
VagrantPlugins::GuestRedHat::Plugin
.components
.guest_capabilities[:redhat]
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
cap.rsync_install(machine)
expect(comm.received_commands[0]).to match(/install rsync/)
end
end
end