Sha256: 463b88d8646463d4bb130cd8f9378643eb2410bd2a218c121bd437a2b4942fa2

Contents?: true

Size: 1.93 KB

Versions: 40

Compression:

Stored size: 1.93 KB

Contents

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

describe Vagrant::Config::Loader do
  include_context "unit"

  let(:instance) { described_class.new }

  it "should ignore non-existent load order keys" do
    instance.load_order = [:foo]
    instance.load
  end

  it "should load and return the configuration" do
    proc = Proc.new do |config|
      config.vagrant.dotfile_name = "foo"
    end

    instance.load_order = [:proc]
    instance.set(:proc, proc)
    config = instance.load

    config.vagrant.dotfile_name.should == "foo"
  end

  it "should only run the same proc once" do
    count = 0
    proc = Proc.new do |config|
      config.vagrant.dotfile_name = "foo"
      count += 1
    end

    instance.load_order = [:proc]
    instance.set(:proc, proc)

    5.times do
      result = instance.load

      # Verify the config result
      result.vagrant.dotfile_name.should == "foo"

      # Verify the count is only one
      count.should == 1
    end
  end

  it "should only load configuration files once" do
    $_config_data = 0

    # We test both setting a file multiple times as well as multiple
    # loads, since both should not cache the data.
    file = temporary_file("$_config_data += 1")
    instance.load_order = [:file]
    5.times { instance.set(:file, file) }
    5.times { instance.load }

    $_config_data.should == 1
  end

  it "should not clear the cache if setting to the same value multiple times" do
    $_config_data = 0

    file = temporary_file("$_config_data += 1")

    instance.load_order = [:proc]
    instance.set(:proc, file)
    5.times { instance.load }

    instance.set(:proc, file)
    5.times { instance.load }

    $_config_data.should == 1
  end

  it "should raise proper error if there is a syntax error in a Vagrantfile" do
    instance.load_order = [:file]
    expect { instance.set(:file, temporary_file("Vagrant:^Config")) }.
      to raise_exception(Vagrant::Errors::VagrantfileSyntaxError)
  end
end

Version data entries

40 entries across 40 versions & 6 rubygems

Version Path
bmhatfield-vagrant-1.0.10 test/unit/vagrant/config/loader_test.rb
bmhatfield-vagrant-1.0.9 test/unit/vagrant/config/loader_test.rb
bmhatfield-vagrant-1.0.8 test/unit/vagrant/config/loader_test.rb
bmhatfield-vagrant-1.0.7 test/unit/vagrant/config/loader_test.rb
vagrantup-1.0.7 test/unit/vagrant/config/loader_test.rb
vagrantup-1.0.6 test/unit/vagrant/config/loader_test.rb
vagrantup-1.0.5 test/unit/vagrant/config/loader_test.rb
vagrantup-1.0.4 test/unit/vagrant/config/loader_test.rb
vagrantup-1.0.3 test/unit/vagrant/config/loader_test.rb
vagrantup-1.0.2 test/unit/vagrant/config/loader_test.rb
vagrantup-1.0.1 test/unit/vagrant/config/loader_test.rb
vagrantup-1.0.0 test/unit/vagrant/config/loader_test.rb
vagrantup-0.9.99.2 test/unit/vagrant/config/loader_test.rb
vagrantup-0.9.99.1 test/unit/vagrant/config/loader_test.rb
vagrantup-0.9.7 test/unit/vagrant/config/loader_test.rb
vagrantup-0.9.6 test/unit/vagrant/config/loader_test.rb
vagrantup-0.9.5 test/unit/vagrant/config/loader_test.rb
vagrantup-0.9.4 test/unit/vagrant/config/loader_test.rb
vagrantup-0.9.3 test/unit/vagrant/config/loader_test.rb
vagrantup-0.9.2 test/unit/vagrant/config/loader_test.rb