Sha256: 6a0a0d7d662cf7b441d401a70a5c7f937dfe881ce6aa7b098a336193d8ebe491

Contents?: true

Size: 1.74 KB

Versions: 38

Compression:

Stored size: 1.74 KB

Contents

require File.expand_path("../../../../base", __FILE__)

describe Vagrant::Plugin::V2::Config do
  include_context "unit"

  let(:foo_class) do
    Class.new(described_class) do
      attr_accessor :one
      attr_accessor :two
    end
  end

  let(:unset_value) { described_class.const_get("UNSET_VALUE") }

  subject { foo_class.new }

  describe "#merge" do
    it "should merge by default by simply copying each instance variable" do
      one = foo_class.new
      one.one = 2
      one.two = 1

      two = foo_class.new
      two.two = 5

      result = one.merge(two)
      expect(result.one).to eq(2)
      expect(result.two).to eq(5)
    end

    it "prefers any set value over an UNSET_VALUE" do
      one = foo_class.new
      one.one = 1
      one.two = 2

      two = foo_class.new
      two.one = unset_value
      two.two = 5

      result = one.merge(two)
      expect(result.one).to eq(1)
      expect(result.two).to eq(5)
    end

    it "doesn't merge values that start with a double underscore" do
      one = foo_class.new
      one.one = 1
      one.two = 1
      one.instance_variable_set(:@__bar, "one")

      two = foo_class.new
      two.two = 2
      two.instance_variable_set(:@__bar, "two")

      # Merge and verify
      result = one.merge(two)
      expect(result.one).to eq(1)
      expect(result.two).to eq(2)
      expect(result.instance_variable_get(:@__bar)).to be_nil
    end
  end

  describe "#method_missing" do
    it "returns a DummyConfig object" do
      expect(subject.i_should_not_exist).
        to be_kind_of(Vagrant::Config::V2::DummyConfig)
    end

    it "raises an error if finalized (internally)" do
      subject._finalize!

      expect { subject.i_should_not_exist }.
        to raise_error(NoMethodError)
    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/vagrant/plugin/v2/config_test.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-aws-detiber-0.7.2.pre.4 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-aws-detiber-0.7.2.pre.3 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-aws-detiber-0.7.2.pre.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-unbundled-2.0.2.0 test/unit/vagrant/plugin/v2/config_test.rb
vagrant-unbundled-2.0.1.0 test/unit/vagrant/plugin/v2/config_test.rb
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-unbundled-2.0.0.1 test/unit/vagrant/plugin/v2/config_test.rb
vagrant-unbundled-1.9.8.1 test/unit/vagrant/plugin/v2/config_test.rb
vagrant-unbundled-1.9.7.1 test/unit/vagrant/plugin/v2/config_test.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/vagrant/plugin/v2/config_test.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/vagrant/plugin/v2/config_test.rb