Sha256: 7baa29c6f9938d75c0447aeb38f54cc63e462b89f482f1c913c87843bb58ff30

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 KB

Contents

shared_context "parallels" do
  let(:parallels_context) { true                                }
  let(:uuid)              { "1234-here-is-uuid-5678"            }
  let(:parallels_version) { "9"                                 }
  let(:subprocess)        { double("Vagrant::Util::Subprocess") }

  # this is a helper that returns a duck type suitable from a system command
  # execution; allows setting exit_code, stdout, and stderr in stubs.
  def subprocess_result(options={})
    defaults = {exit_code: 0, stdout: "", stderr: ""}
    double("subprocess_result", defaults.merge(options))
  end

  before do
    # we don't want unit tests to ever run commands on the system; so we wire
    # in a double to ensure any unexpected messages raise exceptions
    stub_const("Vagrant::Util::Subprocess", subprocess)

    # drivers will blow up on instantiation if they cannot determine the
    # Parallels Desktop version, so wire this stub in automatically
    subprocess.stub(:execute).
      with("prlctl", "--version", an_instance_of(Hash)).
      and_return(subprocess_result(stdout: "prlctl version #{parallels_version}.23456.987654"))

    # drivers also call vm_exists? during init;
    subprocess.stub(:execute).
      with("prlctl", "list", uuid, kind_of(Hash)).
      and_return(subprocess_result(exit_code: 0))
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
vagrant-parallels-1.0.6 test/unit/support/shared/parallels_context.rb
vagrant-parallels-1.0.6.rc1 test/unit/support/shared/parallels_context.rb
vagrant-parallels-1.0.5 test/unit/support/shared/parallels_context.rb
vagrant-parallels-1.0.4 test/unit/support/shared/parallels_context.rb
vagrant-parallels-1.0.3 test/unit/support/shared/parallels_context.rb
vagrant-parallels-1.0.2 test/unit/support/shared/parallels_context.rb
vagrant-parallels-1.0.1 test/unit/support/shared/parallels_context.rb
vagrant-parallels-1.0.0 test/unit/support/shared/parallels_context.rb
vagrant-parallels-0.2.2 test/unit/support/shared/parallels_context.rb
vagrant-parallels-0.2.2.rc1 test/unit/support/shared/parallels_context.rb