Sha256: 688ef0606a2a6be4c934f4d7838716139a0909e60cbea8f19ff217505596053e

Contents?: true

Size: 1.86 KB

Versions: 15

Compression:

Stored size: 1.86 KB

Contents

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

require Vagrant.source_root.join("plugins/providers/virtualbox/config")

describe VagrantPlugins::ProviderVirtualBox::Config do
  let(:machine) { double("machine") }

  def assert_invalid
    errors = subject.validate(machine)
    if !errors.values.any? { |v| !v.empty? }
      raise "No errors: #{errors.inspect}"
    end
  end

  def assert_valid
    errors = subject.validate(machine)
    if !errors.values.all? { |v| v.empty? }
      raise "Errors: #{errors.inspect}"
    end
  end

  def valid_defaults
    subject.image = "foo"
  end

  before do
    vm_config = double("vm_config")
    allow(vm_config).to receive(:networks).and_return([])
    config = double("config")
    allow(config).to receive(:vm).and_return(vm_config)
    allow(machine).to receive(:config).and_return(config)
  end

  its "valid by default" do
    subject.finalize!
    assert_valid
  end

  context "defaults" do
    before { subject.finalize! }

    it { expect(subject.check_guest_additions).to be(true) }
    it { expect(subject.gui).to be(false) }
    it { expect(subject.name).to be_nil }
    it { expect(subject.functional_vboxsf).to be(true) }

    it "should have one NAT adapter" do
      expect(subject.network_adapters).to eql({
        1 => [:nat, {}],
      })
    end
  end

  describe "#merge" do
    let(:one) { described_class.new }
    let(:two) { described_class.new }

    subject { one.merge(two) }

    it "merges the customizations" do
      one.customize ["foo"]
      two.customize ["bar"]

      expect(subject.customizations).to eq([
        ["pre-boot", ["foo"]],
        ["pre-boot", ["bar"]]])
    end
  end

  describe "#network_adapter" do
    it "configures additional adapters" do
      subject.network_adapter(2, :bridged, auto_config: true)
      expect(subject.network_adapters[2]).to eql(
        [:bridged, auto_config: true])
    end
  end
end

Version data entries

15 entries across 11 versions & 4 rubygems

Version Path
vagrant-packet-0.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-aws-detiber-0.7.2.pre.4 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-aws-detiber-0.7.2.pre.3 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-aws-detiber-0.7.2.pre.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-unbundled-2.0.2.0 test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-unbundled-2.0.1.0 test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-unbundled-2.0.0.1 test/unit/plugins/providers/virtualbox/config_test.rb
vagrant-unbundled-1.9.8.1 test/unit/plugins/providers/virtualbox/config_test.rb