This conversion is done by Transpec 1.10.2 with the following command:
transpec test/unit/
* 507 conversions
from: obj.should
to: expect(obj).to
* 394 conversions
from: == expected
to: eq(expected)
* 260 conversions
from: obj.should_receive(:message)
to: expect(obj).to receive(:message)
* 85 conversions
from: obj.stub(:message)
to: allow(obj).to receive(:message)
* 25 conversions
from: its(:attr) { }
to: describe '#attr' do subject { super().attr }; it { } end
* 19 conversions
from: obj.should_not
to: expect(obj).not_to
* 7 conversions
from: obj.should_not_receive(:message)
to: expect(obj).not_to receive(:message)
* 3 conversions
from: Klass.any_instance.should_receive(:message)
to: expect_any_instance_of(Klass).to receive(:message)
98 lines
2.8 KiB
Ruby
98 lines
2.8 KiB
Ruby
require_relative "../../../base"
|
|
|
|
require Vagrant.source_root.join("plugins/synced_folders/rsync/synced_folder")
|
|
|
|
describe VagrantPlugins::SyncedFolderRSync::SyncedFolder do
|
|
include_context "unit"
|
|
|
|
let(:iso_env) do
|
|
# We have to create a Vagrantfile so there is a root path
|
|
env = isolated_environment
|
|
env.vagrantfile("")
|
|
env.create_vagrant_env
|
|
end
|
|
|
|
let(:guest) { double("guest") }
|
|
let(:host) { double("host") }
|
|
let(:machine) { iso_env.machine(iso_env.machine_names[0], :dummy) }
|
|
|
|
let(:helper_class) { VagrantPlugins::SyncedFolderRSync::RsyncHelper }
|
|
|
|
before do
|
|
machine.env.stub(host: host)
|
|
machine.stub(guest: guest)
|
|
end
|
|
|
|
describe "#usable?" do
|
|
it "is usable if rsync can be found" do
|
|
expect(Vagrant::Util::Which).to receive(:which).with("rsync").and_return(true)
|
|
expect(subject.usable?(machine)).to be_true
|
|
end
|
|
|
|
it "is not usable if rsync cant be found" do
|
|
expect(Vagrant::Util::Which).to receive(:which).with("rsync").and_return(false)
|
|
expect(subject.usable?(machine)).to be_false
|
|
end
|
|
|
|
it "raises an exception if asked to" do
|
|
expect(Vagrant::Util::Which).to receive(:which).with("rsync").and_return(false)
|
|
expect { subject.usable?(machine, true) }.
|
|
to raise_error(Vagrant::Errors::RSyncNotFound)
|
|
end
|
|
end
|
|
|
|
describe "#enable" do
|
|
let(:ssh_info) {{
|
|
private_key_path: [],
|
|
}}
|
|
|
|
before do
|
|
machine.stub(ssh_info: ssh_info)
|
|
allow(guest).to receive(:capability?).with(:rsync_installed)
|
|
end
|
|
|
|
it "rsyncs each folder" do
|
|
folders = [
|
|
[:one, {}],
|
|
[:two, {}],
|
|
]
|
|
|
|
folders.each do |_, opts|
|
|
expect(helper_class).to receive(:rsync_single).
|
|
with(machine, ssh_info, opts).
|
|
ordered
|
|
end
|
|
|
|
subject.enable(machine, folders, {})
|
|
end
|
|
|
|
it "installs rsync if capable" do
|
|
folders = [ [:foo, {}] ]
|
|
|
|
allow(helper_class).to receive(:rsync_single)
|
|
|
|
allow(guest).to receive(:capability?).with(:rsync_installed).and_return(true)
|
|
allow(guest).to receive(:capability?).with(:rsync_install).and_return(true)
|
|
|
|
expect(guest).to receive(:capability).with(:rsync_installed).and_return(false)
|
|
expect(guest).to receive(:capability).with(:rsync_install)
|
|
|
|
subject.enable(machine, folders, {})
|
|
end
|
|
|
|
it "errors if rsync not installable" do
|
|
folders = [ [:foo, {}] ]
|
|
|
|
allow(helper_class).to receive(:rsync_single)
|
|
|
|
allow(guest).to receive(:capability?).with(:rsync_installed).and_return(true)
|
|
allow(guest).to receive(:capability?).with(:rsync_install).and_return(false)
|
|
|
|
expect(guest).to receive(:capability).with(:rsync_installed).and_return(false)
|
|
|
|
expect { subject.enable(machine, folders, {}) }.
|
|
to raise_error(Vagrant::Errors::RSyncNotInstalledInGuest)
|
|
end
|
|
end
|
|
end
|