Sha256: 3f00e51fe195eec7925267c26a0023ae67518136969ca3cb7abc035636cf3bef

Contents?: true

Size: 1.71 KB

Versions: 45

Compression:

Stored size: 1.71 KB

Contents

require 'test_helper'

class CheckBoxVMActionTest < Test::Unit::TestCase
  setup do
    @klass = Vagrant::Action::VM::CheckBox
  end

  context "calling" do
    should "raise error if box not specified" do
      app, env = action_env(vagrant_env(vagrantfile(<<-vf)))
        config.vm.box = nil
      vf

      instance = @klass.new(app, env)
      app.expects(:call).never

      assert_raises(Vagrant::Errors::BoxNotSpecified) {
        instance.call(env)
      }
    end

    should "error if box does not exist and URL not specified" do
      app, env = action_env(vagrant_env(vagrantfile(<<-vf)))
        config.vm.box = "yo"
        config.vm.box_url = nil
      vf

      instance = @klass.new(app, env)
      app.expects(:call).never
      env.env.boxes.expects(:find).with(env["config"].vm.box).returns(nil)

      assert_raises(Vagrant::Errors::BoxSpecifiedDoesntExist) {
        instance.call(env)
      }
    end

    should "attempt to download box and continue if URL specified" do
      app, env = action_env(vagrant_env(vagrantfile(<<-vf)))
        config.vm.box = "yo"
        config.vm.box_url = "http://google.com"
      vf

      # Save this for later because the expecations below clobber it
      vms = env.env.vms

      instance = @klass.new(app, env)
      seq = sequence("seq")
      env.env.boxes.expects(:find).returns(nil)
      Vagrant::Box.expects(:add).with(env.env, env["config"].vm.box, env["config"].vm.box_url).in_sequence(seq)
      env.env.boxes.expects(:reload!).in_sequence(seq)
      vms.each do |name, vm|
        vm.env.expects(:reload_config!).in_sequence(seq)
      end
      app.expects(:call).with(env).once.in_sequence(seq)

      assert_nothing_raised {
        instance.call(env)
      }
    end
  end
end

Version data entries

45 entries across 45 versions & 6 rubygems

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