Sha256: 5cfd32fd9cf98842c484f6b3c4966c32074e1753668e44fd529fa0bb16db7f90

Contents?: true

Size: 1.57 KB

Versions: 40

Compression:

Stored size: 1.57 KB

Contents

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

describe Vagrant::BoxCollection do
  include_context "unit"

  let(:environment) { isolated_environment }
  let(:action_runner) { double("action runner") }
  let(:instance)    { described_class.new(environment.boxes_dir, action_runner) }

  it "should list all available boxes" do
    # No boxes yet.
    instance.length.should == 0

    # Add some boxes to the environment and try again
    environment.box("foo")
    environment.box("bar")
    instance.reload!
    instance.length.should == 2
  end

  describe "finding" do
    it "should return nil if it can't find the box" do
      instance.find("foo").should be_nil
    end

    it "should return a box instance for any boxes it does find" do
      environment.box("foo")
      result = instance.find("foo")
      result.should be_kind_of(Vagrant::Box)
      result.name.should == "foo"
    end
  end

  it "should throw an error if the box already exists when adding" do
    environment.box("foo")
    expect { instance.add("foo", "bar") }.to raise_error(Vagrant::Errors::BoxAlreadyExists)
  end

  it "should add the box" do
    name = "foo"
    url  = "bar"

    # Test the invocation of the action runner with the proper name
    # and parameters. We leave the testing of the actual stack to
    # acceptance tests, and individual pieces to unit tests of each
    # step.
    options = {
      :box_name => name,
      :box_url => url,
      :box_directory => instance.directory.join(name)
    }
    action_runner.should_receive(:run).with(:box_add, options)

    instance.add(name, url)
  end
end

Version data entries

40 entries across 40 versions & 6 rubygems

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