Sha256: f8d3ca5cdc33a0c7f3863e1eace0a9cb14e47d5f57d5578b073258ac0da30fda

Contents?: true

Size: 1.78 KB

Versions: 22

Compression:

Stored size: 1.78 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")
    vm_config.stub(networks: [])
    config = double("config")
    config.stub(vm: vm_config)
    machine.stub(config: 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

22 entries across 19 versions & 5 rubygems

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