Sha256: c0b0198c498745458986762fd4101793993e6af019fce17a3ba9cab651fdd278

Contents?: true

Size: 1.95 KB

Versions: 22

Compression:

Stored size: 1.95 KB

Contents

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

require Vagrant.source_root.join("plugins/commands/box/command/remove")

describe VagrantPlugins::CommandBox::Command::Remove do
  include_context "unit"

  let(:argv)     { [] }
  let(:iso_env) do
    # We have to create a Vagrantfile so there is a root path
    env = isolated_environment
    env.vagrantfile("")
    env.create_vagrant_env
  end

  subject { described_class.new(argv, iso_env) }

  let(:action_runner) { double("action_runner") }

  before do
    iso_env.stub(action_runner: action_runner)
  end

  context "with no arguments" do
    it "shows help" do
      expect { subject.execute }.
        to raise_error(Vagrant::Errors::CLIInvalidUsage)
    end
  end

  context "with one argument" do
    let(:argv) { ["foo"] }

    it "invokes the action runner" do
      expect(action_runner).to receive(:run).with { |action, opts|
        expect(opts[:box_name]).to eq("foo")
        expect(opts[:force_confirm_box_remove]).to be_false
        true
      }

      subject.execute
    end

    context "with --force" do
      let(:argv) { super() + ["--force"] }

      it "invokes the action runner with force option" do
        expect(action_runner).to receive(:run).with { |action, opts|
          expect(opts[:box_name]).to eq("foo")
          expect(opts[:force_confirm_box_remove]).to be_true
          true
        }

        subject.execute
      end
    end
  end

  context "with two arguments" do
    let(:argv) { ["foo", "bar"] }

    it "uses the 2nd arg as a provider" do
      expect(action_runner).to receive(:run).with { |action, opts|
        expect(opts[:box_name]).to eq("foo")
        expect(opts[:box_provider]).to eq("bar")
        true
      }

      subject.execute
    end
  end

  context "with more than two arguments" do
    let(:argv) { ["one", "two", "three"] }

    it "shows help" do
      expect { subject.execute }.
        to raise_error(Vagrant::Errors::CLIInvalidUsage)
    end
  end
end

Version data entries

22 entries across 19 versions & 5 rubygems

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