Sha256: 51c419a7efab36041dbb6187e336ee6cf097e7edfec25b2fa475ddced30ba3fd

Contents?: true

Size: 1.48 KB

Versions: 38

Compression:

Stored size: 1.48 KB

Contents

shared_context "virtualbox" do
  include_context "unit"

  let(:vbox_context) { true                                }
  let(:uuid)         { "1234-abcd-5678-efgh"               }
  let(:vbox_version) { "4.3.4"                             }
  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
    # virtualbox version, so wire this stub in automatically
    allow(subprocess).to receive(:execute).
      with("VBoxManage", "--version", an_instance_of(Hash)).
      and_return(subprocess_result(stdout: vbox_version))

    # drivers also call vm_exists? during init;
    allow(subprocess).to receive(:execute).
      with("VBoxManage", "showvminfo", kind_of(String), kind_of(Hash)).
      and_return(subprocess_result(exit_code: 0))
  end

  around do |example|
    # On Windows, we don't want to accidentally call the actual VirtualBox
    with_temp_env("VBOX_INSTALL_PATH" => nil) do
      example.run
    end
  end
end

Version data entries

38 entries across 31 versions & 7 rubygems

Version Path
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/test/unit/support/shared/virtualbox_context.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/support/shared/virtualbox_context.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/support/shared/virtualbox_context.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/support/shared/virtualbox_context.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/support/shared/virtualbox_context.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/support/shared/virtualbox_context.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/support/shared/virtualbox_context.rb
vagrant-aws-detiber-0.7.2.pre.4 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/support/shared/virtualbox_context.rb
vagrant-aws-detiber-0.7.2.pre.3 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/support/shared/virtualbox_context.rb
vagrant-aws-detiber-0.7.2.pre.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/support/shared/virtualbox_context.rb
vagrant-unbundled-2.0.2.0 test/unit/support/shared/virtualbox_context.rb
vagrant-unbundled-2.0.1.0 test/unit/support/shared/virtualbox_context.rb
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/test/unit/support/shared/virtualbox_context.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/test/unit/support/shared/virtualbox_context.rb
vagrant-unbundled-2.0.0.1 test/unit/support/shared/virtualbox_context.rb
vagrant-unbundled-1.9.8.1 test/unit/support/shared/virtualbox_context.rb
vagrant-unbundled-1.9.7.1 test/unit/support/shared/virtualbox_context.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/support/shared/virtualbox_context.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/support/shared/virtualbox_context.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/support/shared/virtualbox_context.rb