Sha256: d550bd5d98493631a737d0dfc61c18ac0e098dd73d701282a8ea644416512859

Contents?: true

Size: 1.74 KB

Versions: 22

Compression:

Stored size: 1.74 KB

Contents

require_relative "../../../../base"

require Vagrant.source_root.join("plugins/synced_folders/rsync/command/rsync")

describe VagrantPlugins::SyncedFolderRSync::Command::Rsync do
  include_context "unit"

  let(:argv) { [] }
  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(:communicator) { double("comm") }

  let(:synced_folders) { {} }

  let(:helper_class) { VagrantPlugins::SyncedFolderRSync::RsyncHelper }

  subject do
    described_class.new(argv, iso_env).tap do |s|
      s.stub(synced_folders: synced_folders)
    end
  end

  before do
    iso_env.machine_names.each do |name|
      m = iso_env.machine(name, iso_env.default_provider)
      m.stub(communicate: communicator)
    end
  end

  describe "#execute" do
    context "with a single machine" do
      let(:ssh_info) {{
        private_key_path: [],
      }}

      let(:machine) { iso_env.machine(iso_env.machine_names[0], iso_env.default_provider) }

      before do
        communicator.stub(ready?: true)
        machine.stub(ssh_info: ssh_info)

        synced_folders[:rsync] = [
          [:one, {}],
          [:two, {}],
        ]
      end

      it "doesn't sync if communicator isn't ready and exits with 1" do
        communicator.stub(ready?: false)

        expect(helper_class).to receive(:rsync_single).never

        expect(subject.execute).to eql(1)
      end

      it "rsyncs each folder and exits successfully" do
        synced_folders[:rsync].each do |_, opts|
          expect(helper_class).to receive(:rsync_single).
            with(machine, ssh_info, opts).
            ordered
        end

        expect(subject.execute).to eql(0)
      end
    end
  end
end

Version data entries

22 entries across 19 versions & 5 rubygems

Version Path
vagrant-unbundled-1.9.7.1 test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-unbundled-1.9.5.1 test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-unbundled-1.9.1.1 test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-unbundled-1.8.5.2 test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-unbundled-1.8.5.1 test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-unbundled-1.8.4.2 test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-unbundled-1.8.4.1 test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-unbundled-1.8.1.2 test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-unbundled-1.8.1.1 test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-309e896975d1/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb