"Fossies" - the Fresh Open Source Software Archive

Member "vagrant-2.2.14/test/unit/plugins/commands/box/command/add_test.rb" (20 Nov 2020, 1665 Bytes) of package /linux/misc/vagrant-2.2.14.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "add_test.rb": 2.2.9_vs_2.2.10.

    1 require File.expand_path("../../../../../base", __FILE__)
    2 
    3 require Vagrant.source_root.join("plugins/commands/box/command/add")
    4 
    5 describe VagrantPlugins::CommandBox::Command::Add do
    6   include_context "unit"
    7 
    8   let(:argv)     { [] }
    9   let(:iso_env) do
   10     # We have to create a Vagrantfile so there is a root path
   11     env = isolated_environment
   12     env.vagrantfile("")
   13     env.create_vagrant_env
   14   end
   15 
   16   subject { described_class.new(argv, iso_env) }
   17 
   18   let(:action_runner) { double("action_runner") }
   19 
   20   before do
   21     allow(iso_env).to receive(:action_runner).and_return(action_runner)
   22   end
   23 
   24   context "with no arguments" do
   25     it "shows help" do
   26       expect { subject.execute }.
   27         to raise_error(Vagrant::Errors::CLIInvalidUsage)
   28     end
   29   end
   30 
   31   context "with one argument" do
   32     let(:argv) { ["foo"] }
   33 
   34     it "executes the runner with the proper actions" do
   35       expect(action_runner).to receive(:run).with(any_args) { |action, opts|
   36         expect(opts[:box_name]).to be_nil
   37         expect(opts[:box_url]).to eq("foo")
   38         true
   39       }
   40 
   41       subject.execute
   42     end
   43   end
   44 
   45   context "with two arguments" do
   46     let(:argv) { ["foo", "bar"] }
   47 
   48     it "executes the runner with the proper actions" do
   49       expect(action_runner).to receive(:run).with(any_args) { |action, opts|
   50         expect(opts[:box_name]).to eq("foo")
   51         expect(opts[:box_url]).to eq("bar")
   52         true
   53       }
   54 
   55       subject.execute
   56     end
   57   end
   58 
   59   context "with more than two arguments" do
   60     let(:argv) { ["one", "two", "three"] }
   61 
   62     it "shows help" do
   63       expect { subject.execute }.
   64         to raise_error(Vagrant::Errors::CLIInvalidUsage)
   65     end
   66   end
   67 end