Merge pull request #8850 from briancain/UPDATE-RSPEC
Update rspec to recent version and fix deprecations
This commit is contained in:
commit
7cdff2556b
|
@ -3,8 +3,8 @@ require "rubygems"
|
||||||
|
|
||||||
# Gems
|
# Gems
|
||||||
require "checkpoint"
|
require "checkpoint"
|
||||||
require "rspec/autorun"
|
|
||||||
require "webmock/rspec"
|
require "webmock/rspec"
|
||||||
|
require "rspec/its"
|
||||||
|
|
||||||
# Require Vagrant itself so we can reference the proper
|
# Require Vagrant itself so we can reference the proper
|
||||||
# classes to test.
|
# classes to test.
|
||||||
|
@ -33,8 +33,6 @@ VAGRANT_TEST_CWD = Dir.mktmpdir("vagrant-test-cwd")
|
||||||
|
|
||||||
# Configure RSpec
|
# Configure RSpec
|
||||||
RSpec.configure do |c|
|
RSpec.configure do |c|
|
||||||
c.treat_symbols_as_metadata_keys_with_true_values = true
|
|
||||||
|
|
||||||
if Vagrant::Util::Platform.windows?
|
if Vagrant::Util::Platform.windows?
|
||||||
c.filter_run_excluding :skip_windows
|
c.filter_run_excluding :skip_windows
|
||||||
else
|
else
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe VagrantPlugins::CommandBox::Command::Add do
|
||||||
let(:action_runner) { double("action_runner") }
|
let(:action_runner) { double("action_runner") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
iso_env.stub(action_runner: action_runner)
|
allow(iso_env).to receive(:action_runner).and_return(action_runner)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with no arguments" do
|
context "with no arguments" do
|
||||||
|
@ -32,7 +32,7 @@ describe VagrantPlugins::CommandBox::Command::Add do
|
||||||
let(:argv) { ["foo"] }
|
let(:argv) { ["foo"] }
|
||||||
|
|
||||||
it "executes the runner with the proper actions" do
|
it "executes the runner with the proper actions" do
|
||||||
expect(action_runner).to receive(:run).with { |action, **opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, **opts|
|
||||||
expect(opts[:box_name]).to be_nil
|
expect(opts[:box_name]).to be_nil
|
||||||
expect(opts[:box_url]).to eq("foo")
|
expect(opts[:box_url]).to eq("foo")
|
||||||
true
|
true
|
||||||
|
@ -46,7 +46,7 @@ describe VagrantPlugins::CommandBox::Command::Add do
|
||||||
let(:argv) { ["foo", "bar"] }
|
let(:argv) { ["foo", "bar"] }
|
||||||
|
|
||||||
it "executes the runner with the proper actions" do
|
it "executes the runner with the proper actions" do
|
||||||
expect(action_runner).to receive(:run).with { |action, **opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, **opts|
|
||||||
expect(opts[:box_name]).to eq("foo")
|
expect(opts[:box_name]).to eq("foo")
|
||||||
expect(opts[:box_url]).to eq("bar")
|
expect(opts[:box_url]).to eq("bar")
|
||||||
true
|
true
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe VagrantPlugins::CommandBox::Command::Remove do
|
||||||
let(:action_runner) { double("action_runner") }
|
let(:action_runner) { double("action_runner") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
iso_env.stub(action_runner: action_runner)
|
allow(iso_env).to receive(:action_runner).and_return(action_runner)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with no arguments" do
|
context "with no arguments" do
|
||||||
|
@ -32,9 +32,9 @@ describe VagrantPlugins::CommandBox::Command::Remove do
|
||||||
let(:argv) { ["foo"] }
|
let(:argv) { ["foo"] }
|
||||||
|
|
||||||
it "invokes the action runner" do
|
it "invokes the action runner" do
|
||||||
expect(action_runner).to receive(:run).with { |action, opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, opts|
|
||||||
expect(opts[:box_name]).to eq("foo")
|
expect(opts[:box_name]).to eq("foo")
|
||||||
expect(opts[:force_confirm_box_remove]).to be_false
|
expect(opts[:force_confirm_box_remove]).to be(false)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,9 +45,9 @@ describe VagrantPlugins::CommandBox::Command::Remove do
|
||||||
let(:argv) { super() + ["--force"] }
|
let(:argv) { super() + ["--force"] }
|
||||||
|
|
||||||
it "invokes the action runner with force option" do
|
it "invokes the action runner with force option" do
|
||||||
expect(action_runner).to receive(:run).with { |action, opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, opts|
|
||||||
expect(opts[:box_name]).to eq("foo")
|
expect(opts[:box_name]).to eq("foo")
|
||||||
expect(opts[:force_confirm_box_remove]).to be_true
|
expect(opts[:force_confirm_box_remove]).to be(true)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ describe VagrantPlugins::CommandBox::Command::Remove do
|
||||||
let(:argv) { ["foo", "bar"] }
|
let(:argv) { ["foo", "bar"] }
|
||||||
|
|
||||||
it "uses the 2nd arg as a provider" do
|
it "uses the 2nd arg as a provider" do
|
||||||
expect(action_runner).to receive(:run).with { |action, opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, opts|
|
||||||
expect(opts[:box_name]).to eq("foo")
|
expect(opts[:box_name]).to eq("foo")
|
||||||
expect(opts[:box_provider]).to eq("bar")
|
expect(opts[:box_provider]).to eq("bar")
|
||||||
true
|
true
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe VagrantPlugins::CommandBox::Command::Repackage do
|
||||||
let(:action_runner) { double("action_runner") }
|
let(:action_runner) { double("action_runner") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
iso_env.stub(action_runner: action_runner)
|
allow(iso_env).to receive(:action_runner).and_return(action_runner)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with no arguments" do
|
context "with no arguments" do
|
||||||
|
@ -47,9 +47,7 @@ describe VagrantPlugins::CommandBox::Command::Repackage do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with three arguments" do
|
context "with three arguments" do
|
||||||
it "repackages the box with the given provider" do
|
it "repackages the box with the given provider"
|
||||||
pending
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with more than three arguments" do
|
context "with more than three arguments" do
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
|
||||||
subject { described_class.new(argv, iso_env) }
|
subject { described_class.new(argv, iso_env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
iso_env.stub(action_runner: action_runner)
|
allow(iso_env).to receive(:action_runner).and_return(action_runner)
|
||||||
machine.config.vm.box = "foo"
|
machine.config.vm.box = "foo"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
|
||||||
|
|
||||||
subject.execute
|
subject.execute
|
||||||
|
|
||||||
expect(called).to be_false
|
expect(called).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does update if there is an update" do
|
it "does update if there is an update" do
|
||||||
|
@ -108,7 +108,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
|
||||||
|
|
||||||
subject.execute
|
subject.execute
|
||||||
|
|
||||||
expect(action_called).to be_true
|
expect(action_called).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if there are multiple providers" do
|
it "raises an error if there are multiple providers" do
|
||||||
|
@ -162,7 +162,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
|
||||||
|
|
||||||
subject.execute
|
subject.execute
|
||||||
|
|
||||||
expect(action_called).to be_true
|
expect(action_called).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if that provider doesn't exist" do
|
it "raises an error if that provider doesn't exist" do
|
||||||
|
@ -206,14 +206,14 @@ describe VagrantPlugins::CommandBox::Command::Update do
|
||||||
expect(opts[:box_download_ca_cert]).to eq("foo")
|
expect(opts[:box_download_ca_cert]).to eq("foo")
|
||||||
expect(opts[:box_download_ca_path]).to eq("bar")
|
expect(opts[:box_download_ca_path]).to eq("bar")
|
||||||
expect(opts[:box_client_cert]).to eq("baz")
|
expect(opts[:box_client_cert]).to eq("baz")
|
||||||
expect(opts[:box_download_insecure]).to be_true
|
expect(opts[:box_download_insecure]).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
opts
|
opts
|
||||||
end
|
end
|
||||||
|
|
||||||
subject.execute
|
subject.execute
|
||||||
expect(action_called).to be_true
|
expect(action_called).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
|
||||||
box_dir = test_iso_env.box3("foo", "1.0", :virtualbox)
|
box_dir = test_iso_env.box3("foo", "1.0", :virtualbox)
|
||||||
box = Vagrant::Box.new(
|
box = Vagrant::Box.new(
|
||||||
"foo", :virtualbox, "1.0", box_dir, metadata_url: "foo")
|
"foo", :virtualbox, "1.0", box_dir, metadata_url: "foo")
|
||||||
box.stub(has_update?: nil)
|
allow(box).to receive(:has_update?).and_return(nil)
|
||||||
box
|
box
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't update boxes if they're up-to-date" do
|
it "doesn't update boxes if they're up-to-date" do
|
||||||
machine.stub(box: box)
|
allow(machine).to receive(:box).and_return(box)
|
||||||
expect(box).to receive(:has_update?).
|
expect(box).to receive(:has_update?).
|
||||||
with(machine.config.vm.box_version,
|
with(machine.config.vm.box_version,
|
||||||
{download_options:
|
{download_options:
|
||||||
|
@ -285,7 +285,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
|
||||||
RAW
|
RAW
|
||||||
}
|
}
|
||||||
|
|
||||||
before { machine.stub(box: box) }
|
before { allow(machine).to receive(:box).and_return(box) }
|
||||||
|
|
||||||
it "updates boxes" do
|
it "updates boxes" do
|
||||||
expect(box).to receive(:has_update?).
|
expect(box).to receive(:has_update?).
|
||||||
|
@ -295,7 +295,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
|
||||||
insecure: false}}).
|
insecure: false}}).
|
||||||
and_return([md, md.version("1.1"), md.version("1.1").provider("virtualbox")])
|
and_return([md, md.version("1.1"), md.version("1.1").provider("virtualbox")])
|
||||||
|
|
||||||
expect(action_runner).to receive(:run).with { |action, opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, opts|
|
||||||
expect(opts[:box_url]).to eq(box.metadata_url)
|
expect(opts[:box_url]).to eq(box.metadata_url)
|
||||||
expect(opts[:box_provider]).to eq("virtualbox")
|
expect(opts[:box_provider]).to eq("virtualbox")
|
||||||
expect(opts[:box_version]).to eq("1.1")
|
expect(opts[:box_version]).to eq("1.1")
|
||||||
|
@ -322,11 +322,11 @@ describe VagrantPlugins::CommandBox::Command::Update do
|
||||||
insecure: false}}).
|
insecure: false}}).
|
||||||
and_return([md, md.version("1.1"), md.version("1.1").provider("virtualbox")])
|
and_return([md, md.version("1.1"), md.version("1.1").provider("virtualbox")])
|
||||||
|
|
||||||
expect(action_runner).to receive(:run).with { |action, opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, opts|
|
||||||
expect(opts[:box_download_ca_cert]).to eq("oof")
|
expect(opts[:box_download_ca_cert]).to eq("oof")
|
||||||
expect(opts[:box_download_ca_path]).to eq("rab")
|
expect(opts[:box_download_ca_path]).to eq("rab")
|
||||||
expect(opts[:box_client_cert]).to eq("zab")
|
expect(opts[:box_client_cert]).to eq("zab")
|
||||||
expect(opts[:box_download_insecure]).to be_false
|
expect(opts[:box_download_insecure]).to be(false)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,11 +345,11 @@ describe VagrantPlugins::CommandBox::Command::Update do
|
||||||
and_return([md, md.version("1.1"),
|
and_return([md, md.version("1.1"),
|
||||||
md.version("1.1").provider("virtualbox")])
|
md.version("1.1").provider("virtualbox")])
|
||||||
|
|
||||||
expect(action_runner).to receive(:run).with { |action, opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, opts|
|
||||||
expect(opts[:box_download_ca_cert]).to eq("foo")
|
expect(opts[:box_download_ca_cert]).to eq("foo")
|
||||||
expect(opts[:box_download_ca_path]).to eq("bar")
|
expect(opts[:box_download_ca_path]).to eq("bar")
|
||||||
expect(opts[:box_client_cert]).to eq("baz")
|
expect(opts[:box_client_cert]).to eq("baz")
|
||||||
expect(opts[:box_download_insecure]).to be_true
|
expect(opts[:box_download_insecure]).to be(true)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe VagrantPlugins::CommandInit::Command do
|
||||||
let(:vagrantfile_path) { File.join(env.cwd, "Vagrantfile") }
|
let(:vagrantfile_path) { File.join(env.cwd, "Vagrantfile") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant.plugin("2").manager.stub(commands: {})
|
allow(Vagrant.plugin("2").manager).to receive(:commands).and_return({})
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe VagrantPlugins::CommandListCommands::Command do
|
||||||
subject { described_class.new(argv, iso_env) }
|
subject { described_class.new(argv, iso_env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant.plugin("2").manager.stub(commands: commands)
|
allow(Vagrant.plugin("2").manager).to receive(:commands).and_return(commands)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "execute" do
|
describe "execute" do
|
||||||
|
@ -28,7 +28,7 @@ describe VagrantPlugins::CommandListCommands::Command do
|
||||||
commands[:bar] = [command_lambda("bar", 0), { primary: true }]
|
commands[:bar] = [command_lambda("bar", 0), { primary: true }]
|
||||||
commands[:baz] = [command_lambda("baz", 0), { primary: false }]
|
commands[:baz] = [command_lambda("baz", 0), { primary: false }]
|
||||||
|
|
||||||
expect(iso_env.ui).to receive(:info).with { |message, opts|
|
expect(iso_env.ui).to receive(:info).with(any_args) { |message, opts|
|
||||||
expect(message).to include("foo")
|
expect(message).to include("foo")
|
||||||
expect(message).to include("bar")
|
expect(message).to include("bar")
|
||||||
expect(message).to include("baz")
|
expect(message).to include("baz")
|
||||||
|
|
|
@ -25,7 +25,7 @@ describe VagrantPlugins::CommandPackage::Command do
|
||||||
let(:action_runner) { double("action_runner") }
|
let(:action_runner) { double("action_runner") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
iso_env.stub(action_runner: action_runner)
|
allow(iso_env).to receive(:action_runner).and_return(action_runner)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#execute" do
|
describe "#execute" do
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe VagrantPlugins::CommandPlugin::Action::ExpungePlugins do
|
||||||
subject { described_class.new(app, env) }
|
subject { described_class.new(app, env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant::Plugin::Manager.stub(instance: manager)
|
allow(Vagrant::Plugin::Manager).to receive(:instance).and_return(manager)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#call" do
|
describe "#call" do
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe VagrantPlugins::CommandPlugin::Action::InstallGem do
|
||||||
subject { described_class.new(app, env) }
|
subject { described_class.new(app, env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant::Plugin::Manager.stub(instance: manager)
|
allow(Vagrant::Plugin::Manager).to receive(:instance).and_return(manager)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#call" do
|
describe "#call" do
|
||||||
|
@ -75,7 +75,7 @@ describe VagrantPlugins::CommandPlugin::Action::InstallGem do
|
||||||
before do
|
before do
|
||||||
spec = Gem::Specification.new
|
spec = Gem::Specification.new
|
||||||
spec.name = "foo"
|
spec.name = "foo"
|
||||||
manager.stub(install_plugin: spec)
|
allow(manager).to receive(:install_plugin).and_return(spec)
|
||||||
|
|
||||||
env[:plugin_name] = "foo"
|
env[:plugin_name] = "foo"
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
|
@ -84,7 +84,7 @@ describe VagrantPlugins::CommandPlugin::Action::InstallGem do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should uninstall the plugin" do
|
it "should uninstall the plugin" do
|
||||||
expect(action_runner).to receive(:run).with { |action, newenv|
|
expect(action_runner).to receive(:run).with(any_args) { |action, newenv|
|
||||||
expect(newenv[:plugin_name]).to eql("foo")
|
expect(newenv[:plugin_name]).to eql("foo")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,11 @@ describe VagrantPlugins::CommandPlugin::Action::PluginExistsCheck do
|
||||||
subject { described_class.new(app, env) }
|
subject { described_class.new(app, env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant::Plugin::Manager.stub(instance: manager)
|
allow(Vagrant::Plugin::Manager).to receive(:instance).and_return(manager)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should raise an exception if the plugin doesn't exist" do
|
it "should raise an exception if the plugin doesn't exist" do
|
||||||
manager.stub(installed_plugins: { "foo" => {} })
|
allow(manager).to receive(:installed_plugins).and_return({ "foo" => {} })
|
||||||
expect(app).not_to receive(:call)
|
expect(app).not_to receive(:call)
|
||||||
|
|
||||||
env[:plugin_name] = "bar"
|
env[:plugin_name] = "bar"
|
||||||
|
@ -22,7 +22,7 @@ describe VagrantPlugins::CommandPlugin::Action::PluginExistsCheck do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should call the app if the plugin is installed" do
|
it "should call the app if the plugin is installed" do
|
||||||
manager.stub(installed_plugins: { "bar" => {} })
|
allow(manager).to receive(:installed_plugins).and_return({ "bar" => {} })
|
||||||
expect(app).to receive(:call).once.with(env)
|
expect(app).to receive(:call).once.with(env)
|
||||||
|
|
||||||
env[:plugin_name] = "bar"
|
env[:plugin_name] = "bar"
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe VagrantPlugins::CommandPlugin::Action::UninstallPlugin do
|
||||||
subject { described_class.new(app, env) }
|
subject { described_class.new(app, env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant::Plugin::Manager.stub(instance: manager)
|
allow(Vagrant::Plugin::Manager).to receive(:instance).and_return(manager)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uninstalls the specified plugin" do
|
it "uninstalls the specified plugin" do
|
||||||
|
|
|
@ -11,8 +11,8 @@ describe VagrantPlugins::CommandPlugin::Action::UpdateGems do
|
||||||
subject { described_class.new(app, env) }
|
subject { described_class.new(app, env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant::Plugin::Manager.stub(instance: manager)
|
allow(Vagrant::Plugin::Manager).to receive(:instance).and_return(manager)
|
||||||
manager.stub(installed_specs: [])
|
allow(manager).to receive(:installed_specs).and_return([])
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#call" do
|
describe "#call" do
|
||||||
|
|
|
@ -53,7 +53,7 @@ describe VagrantPlugins::CommandPort::Command do
|
||||||
|
|
||||||
it "ensures the vm is running" do
|
it "ensures the vm is running" do
|
||||||
allow(state).to receive(:id).and_return(:stopped)
|
allow(state).to receive(:id).and_return(:stopped)
|
||||||
expect(env.ui).to receive(:error).with { |message, _|
|
expect(env.ui).to receive(:error).with(any_args) { |message, _|
|
||||||
expect(message).to include("does not support listing forwarded ports")
|
expect(message).to include("does not support listing forwarded ports")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ describe VagrantPlugins::CommandPort::Command do
|
||||||
|
|
||||||
it "shows a friendly error when the capability is not supported" do
|
it "shows a friendly error when the capability is not supported" do
|
||||||
allow(machine.provider).to receive(:capability?).and_return(false)
|
allow(machine.provider).to receive(:capability?).and_return(false)
|
||||||
expect(env.ui).to receive(:error).with { |message, _|
|
expect(env.ui).to receive(:error).with(any_args) { |message, _|
|
||||||
expect(message).to include("does not support listing forwarded ports")
|
expect(message).to include("does not support listing forwarded ports")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ describe VagrantPlugins::CommandPort::Command do
|
||||||
allow(machine.provider).to receive(:capability).with(:forwarded_ports)
|
allow(machine.provider).to receive(:capability).with(:forwarded_ports)
|
||||||
.and_return([])
|
.and_return([])
|
||||||
|
|
||||||
expect(env.ui).to receive(:info).with { |message, _|
|
expect(env.ui).to receive(:info).with(any_args) { |message, _|
|
||||||
expect(message).to include("there are no forwarded ports")
|
expect(message).to include("there are no forwarded ports")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe VagrantPlugins::CommandPush::Command do
|
||||||
subject { described_class.new(argv, env) }
|
subject { described_class.new(argv, env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant.plugin("2").manager.stub(pushes: pushes)
|
allow(Vagrant.plugin("2").manager).to receive(:pushes).and_return(pushes)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#execute" do
|
describe "#execute" do
|
||||||
|
|
|
@ -52,9 +52,8 @@ describe VagrantPlugins::CommandSnapshot::Command::List do
|
||||||
it "prints a message if the vm does not exist" do
|
it "prints a message if the vm does not exist" do
|
||||||
machine.id = nil
|
machine.id = nil
|
||||||
|
|
||||||
expect(iso_env.ui).to receive(:info).with { |message, _|
|
expect(iso_env.ui).to receive(:info).with("==> default: VM not created. Moving on...", anything)
|
||||||
expect(message).to include("VM not created")
|
.and_return({})
|
||||||
}
|
|
||||||
expect(machine).to_not receive(:action)
|
expect(machine).to_not receive(:action)
|
||||||
expect(subject.execute).to eq(0)
|
expect(subject.execute).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe VagrantPlugins::CommandSSHConfig::Command do
|
||||||
subject { described_class.new(argv, iso_env) }
|
subject { described_class.new(argv, iso_env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(ssh_info: ssh_info)
|
allow(machine).to receive(:ssh_info).and_return(ssh_info)
|
||||||
allow(subject).to receive(:with_target_vms) { |&block| block.call machine }
|
allow(subject).to receive(:with_target_vms) { |&block| block.call machine }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe VagrantPlugins::CommandUp::Command do
|
||||||
let(:action_runner) { double("action_runner") }
|
let(:action_runner) { double("action_runner") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
iso_env.stub(action_runner: action_runner)
|
allow(iso_env).to receive(:action_runner).and_return(action_runner)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with no argument" do
|
context "with no argument" do
|
||||||
|
@ -47,7 +47,7 @@ describe VagrantPlugins::CommandUp::Command do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should attempt to use dummy provider" do
|
it "should attempt to use dummy provider" do
|
||||||
expect{ subject.execute }.to raise_error
|
expect{ subject.execute }.to raise_error(Vagrant::Errors::ProviderNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with --provider set" do
|
context "with --provider set" do
|
||||||
|
|
|
@ -30,7 +30,7 @@ describe VagrantPlugins::CommandValidate::Command do
|
||||||
end
|
end
|
||||||
EOH
|
EOH
|
||||||
|
|
||||||
expect(env.ui).to receive(:info).with { |message, _|
|
expect(env.ui).to receive(:info).with(any_args) { |message, _|
|
||||||
expect(message).to include("Vagrantfile validated successfully.")
|
expect(message).to include("Vagrantfile validated successfully.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
|
||||||
describe ".ready?" do
|
describe ".ready?" do
|
||||||
before(&connection_setup)
|
before(&connection_setup)
|
||||||
it "returns true if shell test is successful" do
|
it "returns true if shell test is successful" do
|
||||||
expect(communicator.ready?).to be_true
|
expect(communicator.ready?).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with an invalid shell test" do
|
context "with an invalid shell test" do
|
||||||
|
@ -268,7 +268,7 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
|
||||||
before(&connection_setup)
|
before(&connection_setup)
|
||||||
context "with exit code as zero" do
|
context "with exit code as zero" do
|
||||||
it "returns true" do
|
it "returns true" do
|
||||||
expect(communicator.test("ls")).to be_true
|
expect(communicator.test("ls")).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false" do
|
it "returns false" do
|
||||||
expect(communicator.test("/bin/false")).to be_false
|
expect(communicator.test("/bin/false")).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -585,14 +585,14 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
|
||||||
|
|
||||||
describe ".generate_environment_export" do
|
describe ".generate_environment_export" do
|
||||||
it "should generate bourne shell compatible export" do
|
it "should generate bourne shell compatible export" do
|
||||||
communicator.send(:generate_environment_export, "TEST", "value").should eq("export TEST=\"value\"\n")
|
expect(communicator.send(:generate_environment_export, "TEST", "value")).to eq("export TEST=\"value\"\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with custom template defined" do
|
context "with custom template defined" do
|
||||||
let(:export_command_template){ "setenv %ENV_KEY% %ENV_VALUE%" }
|
let(:export_command_template){ "setenv %ENV_KEY% %ENV_VALUE%" }
|
||||||
|
|
||||||
it "should generate custom export based on template" do
|
it "should generate custom export based on template" do
|
||||||
communicator.send(:generate_environment_export, "TEST", "value").should eq("setenv TEST value\n")
|
expect(communicator.send(:generate_environment_export, "TEST", "value")).to eq("setenv TEST value\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,12 +60,12 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do
|
||||||
describe ".ready?" do
|
describe ".ready?" do
|
||||||
it "returns true if hostname command executes without error" do
|
it "returns true if hostname command executes without error" do
|
||||||
expect(shell).to receive(:cmd).with("hostname").and_return({ exitcode: 0 })
|
expect(shell).to receive(:cmd).with("hostname").and_return({ exitcode: 0 })
|
||||||
expect(subject.ready?).to be_true
|
expect(subject.ready?).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if hostname command fails with a transient error" do
|
it "returns false if hostname command fails with a transient error" do
|
||||||
expect(shell).to receive(:cmd).with("hostname").and_raise(VagrantPlugins::CommunicatorWinRM::Errors::TransientError)
|
expect(shell).to receive(:cmd).with("hostname").and_raise(VagrantPlugins::CommunicatorWinRM::Errors::TransientError)
|
||||||
expect(subject.ready?).to be_false
|
expect(subject.ready?).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if hostname command fails with an unknown error" do
|
it "raises an error if hostname command fails with an unknown error" do
|
||||||
|
@ -112,12 +112,12 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do
|
||||||
describe ".test" do
|
describe ".test" do
|
||||||
it "returns true when exit code is zero" do
|
it "returns true when exit code is zero" do
|
||||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return(good_output)
|
expect(shell).to receive(:powershell).with(kind_of(String)).and_return(good_output)
|
||||||
expect(subject.test("test -d c:/windows")).to be_true
|
expect(subject.test("test -d c:/windows")).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when exit code is non-zero" do
|
it "returns false when exit code is non-zero" do
|
||||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return(bad_output)
|
expect(shell).to receive(:powershell).with(kind_of(String)).and_return(bad_output)
|
||||||
expect(subject.test("test -d /tmp/foobar")).to be_false
|
expect(subject.test("test -d /tmp/foobar")).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when stderr contains output" do
|
it "returns false when stderr contains output" do
|
||||||
|
@ -125,11 +125,11 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do
|
||||||
output.exitcode = 1
|
output.exitcode = 1
|
||||||
output << { stderr: 'this is an error' }
|
output << { stderr: 'this is an error' }
|
||||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return(output)
|
expect(shell).to receive(:powershell).with(kind_of(String)).and_return(output)
|
||||||
expect(subject.test("[-x stuff] && foo")).to be_false
|
expect(subject.test("[-x stuff] && foo")).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when command is testing for linux OS" do
|
it "returns false when command is testing for linux OS" do
|
||||||
expect(subject.test("uname -s | grep Debian")).to be_false
|
expect(subject.test("uname -s | grep Debian")).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,24 +27,24 @@ describe VagrantPlugins::CommunicatorWinRM::Helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the SSH info host if available" do
|
it "returns the SSH info host if available" do
|
||||||
machine.stub(ssh_info: { host: "bar" })
|
allow(machine).to receive(:ssh_info).and_return({ host: "bar" })
|
||||||
expect(subject.winrm_address(machine)).to eq("bar")
|
expect(subject.winrm_address(machine)).to eq("bar")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raise an exception if it can't detect a host" do
|
it "raise an exception if it can't detect a host" do
|
||||||
machine.stub(ssh_info: nil)
|
allow(machine).to receive(:ssh_info).and_return(nil)
|
||||||
expect { subject.winrm_address(machine) }.
|
expect { subject.winrm_address(machine) }.
|
||||||
to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
|
to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raise an exception if it detects an empty host ip" do
|
it "raise an exception if it detects an empty host ip" do
|
||||||
machine.stub(ssh_info: { host: "" })
|
allow(machine).to receive(:ssh_info).and_return({ host: "" })
|
||||||
expect { subject.winrm_address(machine) }.
|
expect { subject.winrm_address(machine) }.
|
||||||
to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
|
to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raise a WinRMNotReady exception if it detects an unset host ip" do
|
it "raise a WinRMNotReady exception if it detects an unset host ip" do
|
||||||
machine.stub(ssh_info: { host: nil })
|
allow(machine).to receive(:ssh_info).and_return({ host: nil })
|
||||||
expect { subject.winrm_address(machine) }.
|
expect { subject.winrm_address(machine) }.
|
||||||
to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
|
to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
|
||||||
end
|
end
|
||||||
|
@ -52,15 +52,15 @@ describe VagrantPlugins::CommunicatorWinRM::Helper do
|
||||||
|
|
||||||
describe ".winrm_info" do
|
describe ".winrm_info" do
|
||||||
before do
|
before do
|
||||||
machine.provider.stub(:capability?).
|
allow(machine.provider).to receive(:capability?)
|
||||||
with(:winrm_info).and_return(false)
|
.with(:winrm_info).and_return(false)
|
||||||
subject.stub(winrm_address: nil)
|
allow(subject).to receive(:winrm_address).and_return(nil)
|
||||||
subject.stub(winrm_port: nil)
|
allow(subject).to receive(:winrm_port).and_return(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns default info if no capability" do
|
it "returns default info if no capability" do
|
||||||
subject.stub(winrm_address: "bar")
|
allow(subject).to receive(:winrm_address).and_return("bar")
|
||||||
subject.stub(winrm_port: 45)
|
allow(subject).to receive(:winrm_port).and_return(45)
|
||||||
|
|
||||||
result = subject.winrm_info(machine)
|
result = subject.winrm_info(machine)
|
||||||
expect(result[:host]).to eq("bar")
|
expect(result[:host]).to eq("bar")
|
||||||
|
@ -68,18 +68,19 @@ describe VagrantPlugins::CommunicatorWinRM::Helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an exception if capability returns nil" do
|
it "raises an exception if capability returns nil" do
|
||||||
machine.provider.stub(:capability?).
|
allow(machine.provider).to receive(:capability?)
|
||||||
with(:winrm_info).and_return(true)
|
.with(:winrm_info).and_return(true)
|
||||||
machine.provider.stub(:capability).with(:winrm_info).and_return(nil)
|
allow(machine.provider).to receive(:capability)
|
||||||
|
.with(:winrm_info).and_return(nil)
|
||||||
|
|
||||||
expect { subject.winrm_info(machine) }.
|
expect { subject.winrm_info(machine) }.
|
||||||
to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
|
to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the proper information if set" do
|
it "returns the proper information if set" do
|
||||||
machine.provider.stub(:capability?).
|
allow(machine.provider).to receive(:capability?)
|
||||||
with(:winrm_info).and_return(true)
|
.with(:winrm_info).and_return(true)
|
||||||
machine.provider.stub(:capability).with(:winrm_info).and_return({
|
allow(machine.provider).to receive(:capability).with(:winrm_info).and_return({
|
||||||
host: "foo",
|
host: "foo",
|
||||||
port: 12,
|
port: 12,
|
||||||
})
|
})
|
||||||
|
@ -90,12 +91,12 @@ describe VagrantPlugins::CommunicatorWinRM::Helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "defaults information if capability doesn't set it" do
|
it "defaults information if capability doesn't set it" do
|
||||||
machine.provider.stub(:capability?).
|
allow(machine.provider).to receive(:capability?)
|
||||||
with(:winrm_info).and_return(true)
|
.with(:winrm_info).and_return(true)
|
||||||
machine.provider.stub(:capability).with(:winrm_info).and_return({})
|
allow(machine.provider).to receive(:capability).with(:winrm_info).and_return({})
|
||||||
|
|
||||||
subject.stub(winrm_address: "bar")
|
allow(subject).to receive(:winrm_address).and_return("bar")
|
||||||
subject.stub(winrm_port: 45)
|
allow(subject).to receive(:winrm_port).and_return(45)
|
||||||
|
|
||||||
result = subject.winrm_info(machine)
|
result = subject.winrm_info(machine)
|
||||||
expect(result[:host]).to eq("bar")
|
expect(result[:host]).to eq("bar")
|
||||||
|
@ -132,8 +133,8 @@ describe VagrantPlugins::CommunicatorWinRM::Helper do
|
||||||
machine.config.winrm.guest_port = 2222
|
machine.config.winrm.guest_port = 2222
|
||||||
machine.config.vm.network "forwarded_port", host: 1234, guest: 2222
|
machine.config.vm.network "forwarded_port", host: 1234, guest: 2222
|
||||||
|
|
||||||
machine.provider.stub(:capability?).with(:forwarded_ports).and_return(true)
|
allow(machine.provider).to receive(:capability?).with(:forwarded_ports).and_return(true)
|
||||||
machine.provider.stub(:capability).with(:forwarded_ports).and_return({
|
allow(machine.provider).to receive(:capability).with(:forwarded_ports).and_return({
|
||||||
1234 => 4567,
|
1234 => 4567,
|
||||||
2456 => 2222,
|
2456 => 2222,
|
||||||
})
|
})
|
||||||
|
|
|
@ -127,7 +127,7 @@ describe VagrantPlugins::CommunicatorWinSSH::Communicator do
|
||||||
describe ".ready?" do
|
describe ".ready?" do
|
||||||
before(&connection_setup)
|
before(&connection_setup)
|
||||||
it "returns true if shell test is successful" do
|
it "returns true if shell test is successful" do
|
||||||
expect(communicator.ready?).to be_true
|
expect(communicator.ready?).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with an invalid shell test" do
|
context "with an invalid shell test" do
|
||||||
|
@ -209,7 +209,7 @@ describe VagrantPlugins::CommunicatorWinSSH::Communicator do
|
||||||
before(&connection_setup)
|
before(&connection_setup)
|
||||||
context "with exit code as zero" do
|
context "with exit code as zero" do
|
||||||
it "returns true" do
|
it "returns true" do
|
||||||
expect(communicator.test("dir")).to be_true
|
expect(communicator.test("dir")).to be_truthy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ describe VagrantPlugins::CommunicatorWinSSH::Communicator do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false" do
|
it "returns false" do
|
||||||
expect(communicator.test("false.exe")).to be_false
|
expect(communicator.test("false.exe")).to be_falsey
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -512,14 +512,14 @@ describe VagrantPlugins::CommunicatorWinSSH::Communicator do
|
||||||
|
|
||||||
describe ".generate_environment_export" do
|
describe ".generate_environment_export" do
|
||||||
it "should generate bourne shell compatible export" do
|
it "should generate bourne shell compatible export" do
|
||||||
communicator.send(:generate_environment_export, "TEST", "value").should eq("export TEST=\"value\"\n")
|
expect(communicator.send(:generate_environment_export, "TEST", "value")).to eq("export TEST=\"value\"\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with custom template defined" do
|
context "with custom template defined" do
|
||||||
let(:export_command_template){ "setenv %ENV_KEY% %ENV_VALUE%" }
|
let(:export_command_template){ "setenv %ENV_KEY% %ENV_VALUE%" }
|
||||||
|
|
||||||
it "should generate custom export based on template" do
|
it "should generate custom export based on template" do
|
||||||
communicator.send(:generate_environment_export, "TEST", "value").should eq("setenv TEST value\n")
|
expect(communicator.send(:generate_environment_export, "TEST", "value")).to eq("setenv TEST value\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,8 +40,6 @@ describe "VagrantPlugins::GuestOmniOS::Cap:RSync" do
|
||||||
expect(comm.received_commands[0]).to match(/'1.2.3.4:#{hostpath}' '#{guestpath}'/)
|
expect(comm.received_commands[0]).to match(/'1.2.3.4:#{hostpath}' '#{guestpath}'/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "mounts with options" do
|
it "mounts with options"
|
||||||
pending "not yet implemented"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,8 +12,8 @@ describe "VagrantPlugins::GuestSmartos::Cap::ChangeHostName" do
|
||||||
let(:config) { double("config", smartos: VagrantPlugins::GuestSmartos::Config.new) }
|
let(:config) { double("config", smartos: VagrantPlugins::GuestSmartos::Config.new) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(:communicate).and_return(comm)
|
allow(machine).to receive(:communicate).and_return(comm)
|
||||||
machine.stub(:config).and_return(config)
|
allow(machine).to receive(:config).and_return(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|
|
@ -7,8 +7,8 @@ describe "VagrantPlugins::VagrantPlugins::Cap::ConfigureNetworks" do
|
||||||
let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(:communicate).and_return(communicator)
|
allow(machine).to receive(:communicate).and_return(communicator)
|
||||||
machine.stub(:config).and_return(config)
|
allow(machine).to receive(:config).and_return(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|
|
@ -8,8 +8,8 @@ describe "VagrantPlugins::GuestSmartos::Cap::Halt" do
|
||||||
let(:shutdown_command){ "pfexec /usr/sbin/poweroff" }
|
let(:shutdown_command){ "pfexec /usr/sbin/poweroff" }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(:communicate).and_return(communicator)
|
allow(machine).to receive(:communicate).and_return(communicator)
|
||||||
machine.stub(:config).and_return(config)
|
allow(machine).to receive(:config).and_return(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe "VagrantPlugins::GuestSmartos::Cap::InsertPublicKey" do
|
||||||
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(:communicate).and_return(comm)
|
allow(machine).to receive(:communicate).and_return(comm)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|
|
@ -13,8 +13,8 @@ describe "VagrantPlugins::GuestSmartos::Cap::MountNFS" do
|
||||||
let(:config) { double("config", smartos: VagrantPlugins::GuestSmartos::Config.new) }
|
let(:config) { double("config", smartos: VagrantPlugins::GuestSmartos::Config.new) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(:communicate).and_return(comm)
|
allow(machine).to receive(:communicate).and_return(comm)
|
||||||
machine.stub(:config).and_return(config)
|
allow(machine).to receive(:config).and_return(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|
|
@ -7,8 +7,8 @@ describe "VagrantPlugins::VagrantPlugins::Cap::Rsync" do
|
||||||
let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(:communicate).and_return(communicator)
|
allow(machine).to receive(:communicate).and_return(communicator)
|
||||||
machine.stub(:config).and_return(config)
|
allow(machine).to receive(:config).and_return(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe VagrantPlugins::GuestWindows::Config do
|
||||||
it "should not default #{attribute} if overridden" do
|
it "should not default #{attribute} if overridden" do
|
||||||
subject.send("#{attribute}=".to_sym, 10)
|
subject.send("#{attribute}=".to_sym, 10)
|
||||||
subject.finalize!
|
subject.finalize!
|
||||||
subject.send(attribute).should == 10
|
expect(subject.send(attribute)).to be(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return error #{attribute} if nil" do
|
it "should return error #{attribute} if nil" do
|
||||||
|
|
|
@ -12,14 +12,14 @@ describe "VagrantPlugins::GuestWindows::GuestNetwork" do
|
||||||
expect(communicator).to receive(:test).with(
|
expect(communicator).to receive(:test).with(
|
||||||
/.+Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "Index=7 and DHCPEnabled=True"/).
|
/.+Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "Index=7 and DHCPEnabled=True"/).
|
||||||
and_return(true)
|
and_return(true)
|
||||||
expect(subject.is_dhcp_enabled(7)).to be_true
|
expect(subject.is_dhcp_enabled(7)).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return false for non-DHCP NICs" do
|
it "should return false for non-DHCP NICs" do
|
||||||
expect(communicator).to receive(:test).with(
|
expect(communicator).to receive(:test).with(
|
||||||
/.+Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "Index=8 and DHCPEnabled=True"/).
|
/.+Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "Index=8 and DHCPEnabled=True"/).
|
||||||
and_return(false)
|
and_return(false)
|
||||||
expect(subject.is_dhcp_enabled(8)).to be_false
|
expect(subject.is_dhcp_enabled(8)).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -147,10 +147,12 @@ EOH
|
||||||
|
|
||||||
it "should retain existing file owner and group IDs" do
|
it "should retain existing file owner and group IDs" do
|
||||||
pending("investigate using a simulated FS to test")
|
pending("investigate using a simulated FS to test")
|
||||||
|
test_with_simulated_fs
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should raise custom exception when chown fails" do
|
it "should raise custom exception when chown fails" do
|
||||||
pending("investigate using a simulated FS to test")
|
pending("investigate using a simulated FS to test")
|
||||||
|
test_with_simulated_fs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,7 +71,7 @@ describe VagrantPlugins::Kernel_V2::PushConfig do
|
||||||
describe "#__compiled_pushes" do
|
describe "#__compiled_pushes" do
|
||||||
it "raises an exception if not finalized" do
|
it "raises an exception if not finalized" do
|
||||||
subject.instance_variable_set(:@__finalized, false)
|
subject.instance_variable_set(:@__finalized, false)
|
||||||
expect { subject.__compiled_pushes }.to raise_error
|
expect { subject.__compiled_pushes }.to raise_error(RuntimeError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a copy of the compiled pushes" do
|
it "returns a copy of the compiled pushes" do
|
||||||
|
|
|
@ -32,10 +32,10 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
env = double("env")
|
env = double("env")
|
||||||
env.stub(root_path: nil)
|
allow(env).to receive(:root_path).and_return(nil)
|
||||||
machine.stub(env: env)
|
allow(machine).to receive(:env).and_return(env)
|
||||||
machine.stub(provider_config: nil)
|
allow(machine).to receive(:provider_config).and_return(nil)
|
||||||
machine.stub(provider_options: {})
|
allow(machine).to receive(:provider_options).and_return({})
|
||||||
|
|
||||||
subject.box = "foo"
|
subject.box = "foo"
|
||||||
end
|
end
|
||||||
|
@ -356,7 +356,7 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
|
||||||
|
|
||||||
config = subject.get_provider_config(:virtualbox)
|
config = subject.get_provider_config(:virtualbox)
|
||||||
expect(config.name).to eq("foo")
|
expect(config.name).to eq("foo")
|
||||||
expect(config.gui).to be_true
|
expect(config.gui).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an exception if there is a problem loading" do
|
it "raises an exception if there is a problem loading" do
|
||||||
|
@ -543,7 +543,7 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
|
||||||
sf = subject.synced_folders
|
sf = subject.synced_folders
|
||||||
expect(sf.length).to eq(1)
|
expect(sf.length).to eq(1)
|
||||||
expect(sf).to have_key("/vagrant")
|
expect(sf).to have_key("/vagrant")
|
||||||
expect(sf["/vagrant"][:disabled]).to be_true
|
expect(sf["/vagrant"][:disabled]).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows overriding previously set options" do
|
it "allows overriding previously set options" do
|
||||||
|
@ -553,7 +553,7 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
|
||||||
sf = subject.synced_folders
|
sf = subject.synced_folders
|
||||||
expect(sf.length).to eq(1)
|
expect(sf.length).to eq(1)
|
||||||
expect(sf).to have_key("/vagrant")
|
expect(sf).to have_key("/vagrant")
|
||||||
expect(sf["/vagrant"][:disabled]).to be_false
|
expect(sf["/vagrant"][:disabled]).to be(false)
|
||||||
expect(sf["/vagrant"][:foo]).to eq(:bar)
|
expect(sf["/vagrant"][:foo]).to eq(:bar)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe VagrantPlugins::DockerProvider::Action::Create do
|
||||||
|
|
||||||
let(:machine) do
|
let(:machine) do
|
||||||
iso_env.machine(iso_env.machine_names[0], :virtualbox).tap do |m|
|
iso_env.machine(iso_env.machine_names[0], :virtualbox).tap do |m|
|
||||||
m.provider.stub(driver: driver)
|
allow(m.provider).to receive(:driver).and_return(driver)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe VagrantPlugins::DockerProvider::Command::Exec do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant.plugin("2").manager.stub(commands: {})
|
allow(Vagrant.plugin("2").manager).to receive(:commands).and_return({})
|
||||||
allow(subject).to receive(:exec_command)
|
allow(subject).to receive(:exec_command)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -46,11 +46,11 @@ describe VagrantPlugins::DockerProvider::Config do
|
||||||
its(:expose) { should eq([]) }
|
its(:expose) { should eq([]) }
|
||||||
its(:cmd) { should eq([]) }
|
its(:cmd) { should eq([]) }
|
||||||
its(:env) { should eq({}) }
|
its(:env) { should eq({}) }
|
||||||
its(:force_host_vm) { should be_false }
|
its(:force_host_vm) { should be(false) }
|
||||||
its(:host_vm_build_dir_options) { should be_nil }
|
its(:host_vm_build_dir_options) { should be_nil }
|
||||||
its(:image) { should be_nil }
|
its(:image) { should be_nil }
|
||||||
its(:name) { should be_nil }
|
its(:name) { should be_nil }
|
||||||
its(:privileged) { should be_false }
|
its(:privileged) { should be(false) }
|
||||||
its(:stop_timeout) { should eq(1) }
|
its(:stop_timeout) { should eq(1) }
|
||||||
its(:vagrant_machine) { should be_nil }
|
its(:vagrant_machine) { should be_nil }
|
||||||
its(:vagrant_vagrantfile) { should be_nil }
|
its(:vagrant_vagrantfile) { should be_nil }
|
||||||
|
@ -63,8 +63,8 @@ describe VagrantPlugins::DockerProvider::Config do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
# By default lets be Linux for validations
|
# By default lets be Linux for validations
|
||||||
Vagrant::Util::Platform.stub(linux: true)
|
allow(Vagrant::Util::Platform).to receive(:linux).and_return(true)
|
||||||
Vagrant::Util::Platform.stub(linux?: true)
|
allow(Vagrant::Util::Platform).to receive(:linux?).and_return(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be invalid if both build dir and image are set" do
|
it "should be invalid if both build dir and image are set" do
|
||||||
|
|
|
@ -47,7 +47,7 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
|
||||||
allow(Tempfile).to receive(:new).with("vagrant-docker-compose").and_return(docker_yml)
|
allow(Tempfile).to receive(:new).with("vagrant-docker-compose").and_return(docker_yml)
|
||||||
allow(docker_yml).to receive(:write)
|
allow(docker_yml).to receive(:write)
|
||||||
allow(docker_yml).to receive(:close)
|
allow(docker_yml).to receive(:close)
|
||||||
subject.stub(:execute) do |*args|
|
allow(subject).to receive(:execute) do |*args|
|
||||||
args.delete_if{|i| i.is_a?(Hash) }
|
args.delete_if{|i| i.is_a?(Hash) }
|
||||||
@cmd = args.join(' ')
|
@cmd = args.join(' ')
|
||||||
end
|
end
|
||||||
|
@ -115,19 +115,21 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container exists' do
|
context 'when container exists' do
|
||||||
before { subject.stub(execute: "foo\n#{cid}\nbar") }
|
before { allow(subject).to receive(:execute)
|
||||||
it { expect(result).to be_true }
|
.and_return("foo\n#{cid}\nbar") }
|
||||||
|
it { expect(result).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container does not exist' do
|
context 'when container does not exist' do
|
||||||
before { subject.stub(execute: "foo\n#{cid}extra\nbar") }
|
before { allow(subject).to receive(:execute)
|
||||||
it { expect(result).to be_false }
|
.and_return("foo\n#{cid}extra\nbar") }
|
||||||
|
it { expect(result).to be_falsey }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#pull' do
|
describe '#pull' do
|
||||||
it 'should pull images' do
|
it 'should pull images' do
|
||||||
subject.should_receive(:execute).with('docker', 'pull', 'foo')
|
expect(subject).to receive(:execute).with('docker', 'pull', 'foo')
|
||||||
subject.pull('foo')
|
subject.pull('foo')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -142,43 +144,47 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container exists' do
|
context 'when container exists' do
|
||||||
before { subject.stub(execute: "foo\n#{cid}\nbar") }
|
before { allow(subject).to receive(:execute)
|
||||||
it { expect(result).to be_true }
|
.and_return("foo\n#{cid}\nbar") }
|
||||||
|
it { expect(result).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container does not exist' do
|
context 'when container does not exist' do
|
||||||
before { subject.stub(execute: "foo\n#{cid}extra\nbar") }
|
before { allow(subject).to receive(:execute)
|
||||||
it { expect(result).to be_false }
|
.and_return("foo\n#{cid}extra\nbar") }
|
||||||
|
it { expect(result).to be_falsey }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#privileged?' do
|
describe '#privileged?' do
|
||||||
it 'identifies privileged containers' do
|
it 'identifies privileged containers' do
|
||||||
subject.stub(inspect_container: {'HostConfig' => {"Privileged" => true}})
|
allow(subject).to receive(:inspect_container)
|
||||||
|
.and_return({'HostConfig' => {"Privileged" => true}})
|
||||||
expect(subject).to be_privileged(cid)
|
expect(subject).to be_privileged(cid)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'identifies unprivileged containers' do
|
it 'identifies unprivileged containers' do
|
||||||
subject.stub(inspect_container: {'HostConfig' => {"Privileged" => false}})
|
allow(subject).to receive(:inspect_container)
|
||||||
|
.and_return({'HostConfig' => {"Privileged" => false}})
|
||||||
expect(subject).to_not be_privileged(cid)
|
expect(subject).to_not be_privileged(cid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#start' do
|
describe '#start' do
|
||||||
context 'when container is running' do
|
context 'when container is running' do
|
||||||
before { subject.stub(running?: true) }
|
before { allow(subject).to receive(:running?).and_return(true) }
|
||||||
|
|
||||||
it 'does not start the container' do
|
it 'does not start the container' do
|
||||||
subject.should_not_receive(:execute).with('docker', 'start', cid)
|
expect(subject).not_to receive(:execute).with('docker', 'start', cid)
|
||||||
subject.start(cid)
|
subject.start(cid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container is not running' do
|
context 'when container is not running' do
|
||||||
before { subject.stub(running?: false) }
|
before { allow(subject).to receive(:running?).and_return(false) }
|
||||||
|
|
||||||
it 'starts the container' do
|
it 'starts the container' do
|
||||||
subject.should_receive(:execute).with('docker', 'start', cid)
|
expect(subject).to receive(:execute).with('docker', 'start', cid)
|
||||||
subject.start(cid)
|
subject.start(cid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -186,24 +192,24 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
|
||||||
|
|
||||||
describe '#stop' do
|
describe '#stop' do
|
||||||
context 'when container is running' do
|
context 'when container is running' do
|
||||||
before { subject.stub(running?: true) }
|
before { allow(subject).to receive(:running?).and_return(true) }
|
||||||
|
|
||||||
it 'stops the container' do
|
it 'stops the container' do
|
||||||
subject.should_receive(:execute).with('docker', 'stop', '-t', '1', cid)
|
expect(subject).to receive(:execute).with('docker', 'stop', '-t', '1', cid)
|
||||||
subject.stop(cid, 1)
|
subject.stop(cid, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "stops the container with the set timeout" do
|
it "stops the container with the set timeout" do
|
||||||
subject.should_receive(:execute).with('docker', 'stop', '-t', '5', cid)
|
expect(subject).to receive(:execute).with('docker', 'stop', '-t', '5', cid)
|
||||||
subject.stop(cid, 5)
|
subject.stop(cid, 5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container is not running' do
|
context 'when container is not running' do
|
||||||
before { subject.stub(running?: false) }
|
before { allow(subject).to receive(:running?).and_return(false) }
|
||||||
|
|
||||||
it 'does not stop container' do
|
it 'does not stop container' do
|
||||||
subject.should_not_receive(:execute).with('docker', 'stop', '-t', '1', cid)
|
expect(subject).not_to receive(:execute).with('docker', 'stop', '-t', '1', cid)
|
||||||
subject.stop(cid, 1)
|
subject.stop(cid, 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -211,7 +217,7 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
|
||||||
|
|
||||||
describe '#rm' do
|
describe '#rm' do
|
||||||
context 'when container has been created' do
|
context 'when container has been created' do
|
||||||
before { subject.stub(created?: true) }
|
before { allow(subject).to receive(:created?).and_return(true) }
|
||||||
|
|
||||||
it 'removes the container' do
|
it 'removes the container' do
|
||||||
expect(subject).to receive(:execute).with("docker-compose", "-f", "docker-compose.yml", "-p", "cwd", "rm", "-f", "docker_1", {})
|
expect(subject).to receive(:execute).with("docker-compose", "-f", "docker-compose.yml", "-p", "cwd", "rm", "-f", "docker_1", {})
|
||||||
|
@ -220,7 +226,7 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container has not been created' do
|
context 'when container has not been created' do
|
||||||
before { subject.stub(created?: false) }
|
before { allow(subject).to receive(:created?).and_return(false) }
|
||||||
|
|
||||||
it 'does not attempt to remove the container' do
|
it 'does not attempt to remove the container' do
|
||||||
expect(subject).not_to receive(:execute).with("docker-compose", "-f", "docker-compose.yml", "-p", "cwd", "rm", "-f", "docker_1", {})
|
expect(subject).not_to receive(:execute).with("docker-compose", "-f", "docker-compose.yml", "-p", "cwd", "rm", "-f", "docker_1", {})
|
||||||
|
@ -232,10 +238,10 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
|
||||||
describe '#inspect_container' do
|
describe '#inspect_container' do
|
||||||
let(:data) { '[{"json": "value"}]' }
|
let(:data) { '[{"json": "value"}]' }
|
||||||
|
|
||||||
before { subject.stub(execute: data) }
|
before { allow(subject).to receive(:execute).and_return(data) }
|
||||||
|
|
||||||
it 'inspects the container' do
|
it 'inspects the container' do
|
||||||
subject.should_receive(:execute).with('docker', 'inspect', cid)
|
expect(subject).to receive(:execute).with('docker', 'inspect', cid)
|
||||||
subject.inspect_container(cid)
|
subject.inspect_container(cid)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -247,10 +253,10 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
|
||||||
describe '#all_containers' do
|
describe '#all_containers' do
|
||||||
let(:containers) { "container1\ncontainer2" }
|
let(:containers) { "container1\ncontainer2" }
|
||||||
|
|
||||||
before { subject.stub(execute: containers) }
|
before { allow(subject).to receive(:execute).and_return(containers) }
|
||||||
|
|
||||||
it 'returns an array of all known containers' do
|
it 'returns an array of all known containers' do
|
||||||
subject.should_receive(:execute).with('docker', 'ps', '-a', '-q', '--no-trunc')
|
expect(subject).to receive(:execute).with('docker', 'ps', '-a', '-q', '--no-trunc')
|
||||||
expect(subject.all_containers).to eq(['container1', 'container2'])
|
expect(subject.all_containers).to eq(['container1', 'container2'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -258,10 +264,10 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
|
||||||
describe '#docker_bridge_ip' do
|
describe '#docker_bridge_ip' do
|
||||||
let(:containers) { " inet 123.456.789.012/16 " }
|
let(:containers) { " inet 123.456.789.012/16 " }
|
||||||
|
|
||||||
before { subject.stub(execute: containers) }
|
before { allow(subject).to receive(:execute).and_return(containers) }
|
||||||
|
|
||||||
it 'returns an array of all known containers' do
|
it 'returns an array of all known containers' do
|
||||||
subject.should_receive(:execute).with('/sbin/ip', '-4', 'addr', 'show', 'scope', 'global', 'docker0')
|
expect(subject).to receive(:execute).with('/sbin/ip', '-4', 'addr', 'show', 'scope', 'global', 'docker0')
|
||||||
expect(subject.docker_bridge_ip).to eq('123.456.789.012')
|
expect(subject.docker_bridge_ip).to eq('123.456.789.012')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe VagrantPlugins::DockerProvider::Driver do
|
||||||
let(:cid) { 'side-1-song-10' }
|
let(:cid) { 'side-1-song-10' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.stub(:execute) { |*args| @cmd = args.join(' ') }
|
allow(subject).to receive(:execute) { |*args| @cmd = args.join(' ') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
|
@ -74,19 +74,19 @@ describe VagrantPlugins::DockerProvider::Driver do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container exists' do
|
context 'when container exists' do
|
||||||
before { subject.stub(execute: "foo\n#{cid}\nbar") }
|
before { allow(subject).to receive(:execute).and_return("foo\n#{cid}\nbar") }
|
||||||
it { expect(result).to be_true }
|
it { expect(result).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container does not exist' do
|
context 'when container does not exist' do
|
||||||
before { subject.stub(execute: "foo\n#{cid}extra\nbar") }
|
before { allow(subject).to receive(:execute).and_return("foo\n#{cid}extra\nbar") }
|
||||||
it { expect(result).to be_false }
|
it { expect(result).to be_falsey }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#pull' do
|
describe '#pull' do
|
||||||
it 'should pull images' do
|
it 'should pull images' do
|
||||||
subject.should_receive(:execute).with('docker', 'pull', 'foo')
|
expect(subject).to receive(:execute).with('docker', 'pull', 'foo')
|
||||||
subject.pull('foo')
|
subject.pull('foo')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -101,43 +101,43 @@ describe VagrantPlugins::DockerProvider::Driver do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container exists' do
|
context 'when container exists' do
|
||||||
before { subject.stub(execute: "foo\n#{cid}\nbar") }
|
before { allow(subject).to receive(:execute).and_return("foo\n#{cid}\nbar") }
|
||||||
it { expect(result).to be_true }
|
it { expect(result).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container does not exist' do
|
context 'when container does not exist' do
|
||||||
before { subject.stub(execute: "foo\n#{cid}extra\nbar") }
|
before { allow(subject).to receive(:execute).and_return("foo\n#{cid}extra\nbar") }
|
||||||
it { expect(result).to be_false }
|
it { expect(result).to be_falsey }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#privileged?' do
|
describe '#privileged?' do
|
||||||
it 'identifies privileged containers' do
|
it 'identifies privileged containers' do
|
||||||
subject.stub(inspect_container: {'HostConfig' => {"Privileged" => true}})
|
allow(subject).to receive(:inspect_container).and_return({'HostConfig' => {"Privileged" => true}})
|
||||||
expect(subject).to be_privileged(cid)
|
expect(subject).to be_privileged(cid)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'identifies unprivileged containers' do
|
it 'identifies unprivileged containers' do
|
||||||
subject.stub(inspect_container: {'HostConfig' => {"Privileged" => false}})
|
allow(subject).to receive(:inspect_container).and_return({'HostConfig' => {"Privileged" => false}})
|
||||||
expect(subject).to_not be_privileged(cid)
|
expect(subject).to_not be_privileged(cid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#start' do
|
describe '#start' do
|
||||||
context 'when container is running' do
|
context 'when container is running' do
|
||||||
before { subject.stub(running?: true) }
|
before { allow(subject).to receive(:running?).and_return(true) }
|
||||||
|
|
||||||
it 'does not start the container' do
|
it 'does not start the container' do
|
||||||
subject.should_not_receive(:execute).with('docker', 'start', cid)
|
expect(subject).to_not receive(:execute).with('docker', 'start', cid)
|
||||||
subject.start(cid)
|
subject.start(cid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container is not running' do
|
context 'when container is not running' do
|
||||||
before { subject.stub(running?: false) }
|
before { allow(subject).to receive(:running?).and_return(false) }
|
||||||
|
|
||||||
it 'starts the container' do
|
it 'starts the container' do
|
||||||
subject.should_receive(:execute).with('docker', 'start', cid)
|
expect(subject).to receive(:execute).with('docker', 'start', cid)
|
||||||
subject.start(cid)
|
subject.start(cid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -145,24 +145,24 @@ describe VagrantPlugins::DockerProvider::Driver do
|
||||||
|
|
||||||
describe '#stop' do
|
describe '#stop' do
|
||||||
context 'when container is running' do
|
context 'when container is running' do
|
||||||
before { subject.stub(running?: true) }
|
before { allow(subject).to receive(:running?).and_return(true) }
|
||||||
|
|
||||||
it 'stops the container' do
|
it 'stops the container' do
|
||||||
subject.should_receive(:execute).with('docker', 'stop', '-t', '1', cid)
|
expect(subject).to receive(:execute).with('docker', 'stop', '-t', '1', cid)
|
||||||
subject.stop(cid, 1)
|
subject.stop(cid, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "stops the container with the set timeout" do
|
it "stops the container with the set timeout" do
|
||||||
subject.should_receive(:execute).with('docker', 'stop', '-t', '5', cid)
|
expect(subject).to receive(:execute).with('docker', 'stop', '-t', '5', cid)
|
||||||
subject.stop(cid, 5)
|
subject.stop(cid, 5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container is not running' do
|
context 'when container is not running' do
|
||||||
before { subject.stub(running?: false) }
|
before { allow(subject).to receive(:running?).and_return(false) }
|
||||||
|
|
||||||
it 'does not stop container' do
|
it 'does not stop container' do
|
||||||
subject.should_not_receive(:execute).with('docker', 'stop', '-t', '1', cid)
|
expect(subject).to_not receive(:execute).with('docker', 'stop', '-t', '1', cid)
|
||||||
subject.stop(cid, 1)
|
subject.stop(cid, 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -170,19 +170,19 @@ describe VagrantPlugins::DockerProvider::Driver do
|
||||||
|
|
||||||
describe '#rm' do
|
describe '#rm' do
|
||||||
context 'when container has been created' do
|
context 'when container has been created' do
|
||||||
before { subject.stub(created?: true) }
|
before { allow(subject).to receive(:created?).and_return(true) }
|
||||||
|
|
||||||
it 'removes the container' do
|
it 'removes the container' do
|
||||||
subject.should_receive(:execute).with('docker', 'rm', '-f', '-v', cid)
|
expect(subject).to receive(:execute).with('docker', 'rm', '-f', '-v', cid)
|
||||||
subject.rm(cid)
|
subject.rm(cid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when container has not been created' do
|
context 'when container has not been created' do
|
||||||
before { subject.stub(created?: false) }
|
before { allow(subject).to receive(:created?).and_return(false) }
|
||||||
|
|
||||||
it 'does not attempt to remove the container' do
|
it 'does not attempt to remove the container' do
|
||||||
subject.should_not_receive(:execute).with('docker', 'rm', '-f', '-v', cid)
|
expect(subject).to_not receive(:execute).with('docker', 'rm', '-f', '-v', cid)
|
||||||
subject.rm(cid)
|
subject.rm(cid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -191,10 +191,10 @@ describe VagrantPlugins::DockerProvider::Driver do
|
||||||
describe '#inspect_container' do
|
describe '#inspect_container' do
|
||||||
let(:data) { '[{"json": "value"}]' }
|
let(:data) { '[{"json": "value"}]' }
|
||||||
|
|
||||||
before { subject.stub(execute: data) }
|
before { allow(subject).to receive(:execute).and_return(data) }
|
||||||
|
|
||||||
it 'inspects the container' do
|
it 'inspects the container' do
|
||||||
subject.should_receive(:execute).with('docker', 'inspect', cid)
|
expect(subject).to receive(:execute).with('docker', 'inspect', cid)
|
||||||
subject.inspect_container(cid)
|
subject.inspect_container(cid)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -206,10 +206,10 @@ describe VagrantPlugins::DockerProvider::Driver do
|
||||||
describe '#all_containers' do
|
describe '#all_containers' do
|
||||||
let(:containers) { "container1\ncontainer2" }
|
let(:containers) { "container1\ncontainer2" }
|
||||||
|
|
||||||
before { subject.stub(execute: containers) }
|
before { allow(subject).to receive(:execute).and_return(containers) }
|
||||||
|
|
||||||
it 'returns an array of all known containers' do
|
it 'returns an array of all known containers' do
|
||||||
subject.should_receive(:execute).with('docker', 'ps', '-a', '-q', '--no-trunc')
|
expect(subject).to receive(:execute).with('docker', 'ps', '-a', '-q', '--no-trunc')
|
||||||
expect(subject.all_containers).to eq(['container1', 'container2'])
|
expect(subject.all_containers).to eq(['container1', 'container2'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -217,10 +217,10 @@ describe VagrantPlugins::DockerProvider::Driver do
|
||||||
describe '#docker_bridge_ip' do
|
describe '#docker_bridge_ip' do
|
||||||
let(:containers) { " inet 123.456.789.012/16 " }
|
let(:containers) { " inet 123.456.789.012/16 " }
|
||||||
|
|
||||||
before { subject.stub(execute: containers) }
|
before { allow(subject).to receive(:execute).and_return(containers) }
|
||||||
|
|
||||||
it 'returns an array of all known containers' do
|
it 'returns an array of all known containers' do
|
||||||
subject.should_receive(:execute).with('/sbin/ip', '-4', 'addr', 'show', 'scope', 'global', 'docker0')
|
expect(subject).to receive(:execute).with('/sbin/ip', '-4', 'addr', 'show', 'scope', 'global', 'docker0')
|
||||||
expect(subject.docker_bridge_ip).to eq('123.456.789.012')
|
expect(subject.docker_bridge_ip).to eq('123.456.789.012')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe VagrantPlugins::DockerProvider::SyncedFolder do
|
||||||
let(:machine) { double("machine") }
|
let(:machine) { double("machine") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(provider_name: :docker)
|
allow(machine).to receive(:provider_name).and_return(:docker)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is usable" do
|
it "is usable" do
|
||||||
|
@ -17,12 +17,12 @@ describe VagrantPlugins::DockerProvider::SyncedFolder do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is not usable if provider isn't docker" do
|
it "is not usable if provider isn't docker" do
|
||||||
machine.stub(provider_name: :virtualbox)
|
allow(machine).to receive(:provider_name).and_return(:virtualbox)
|
||||||
expect(subject).to_not be_usable(machine)
|
expect(subject).to_not be_usable(machine)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if bad provider if specified" do
|
it "raises an error if bad provider if specified" do
|
||||||
machine.stub(provider_name: :virtualbox)
|
allow(machine).to receive(:provider_name).and_return(:virtualbox)
|
||||||
expect { subject.usable?(machine, true) }.
|
expect { subject.usable?(machine, true) }.
|
||||||
to raise_error(VagrantPlugins::DockerProvider::Errors::SyncedFolderNonDocker)
|
to raise_error(VagrantPlugins::DockerProvider::Errors::SyncedFolderNonDocker)
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,63 +12,63 @@ describe VagrantPlugins::HyperV::Provider do
|
||||||
before do
|
before do
|
||||||
stub_const("Vagrant::Util::Platform", platform)
|
stub_const("Vagrant::Util::Platform", platform)
|
||||||
stub_const("Vagrant::Util::PowerShell", powershell)
|
stub_const("Vagrant::Util::PowerShell", powershell)
|
||||||
machine.stub(id: "foo")
|
allow(machine).to receive(:id).and_return("foo")
|
||||||
platform.stub(windows?: true)
|
allow(platform).to receive(:windows?).and_return(true)
|
||||||
platform.stub(windows_admin?: true)
|
allow(platform).to receive(:windows_admin?).and_return(true)
|
||||||
platform.stub(windows_hyperv_admin?: true)
|
allow(platform).to receive(:windows_hyperv_admin?).and_return(true)
|
||||||
powershell.stub(available?: true)
|
allow(powershell).to receive(:available?).and_return(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".usable?" do
|
describe ".usable?" do
|
||||||
subject { described_class }
|
subject { described_class }
|
||||||
|
|
||||||
it "returns false if not windows" do
|
it "returns false if not windows" do
|
||||||
platform.stub(windows?: false)
|
allow(platform).to receive(:windows?).and_return(false)
|
||||||
expect(subject).to_not be_usable
|
expect(subject).to_not be_usable
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if neither an admin nor a hyper-v admin" do
|
it "returns false if neither an admin nor a hyper-v admin" do
|
||||||
platform.stub(windows_admin?: false)
|
allow(platform).to receive(:windows_admin?).and_return(false)
|
||||||
platform.stub(windows_hyperv_admin?: false)
|
allow(platform).to receive(:windows_hyperv_admin?).and_return(false)
|
||||||
expect(subject).to_not be_usable
|
expect(subject).to_not be_usable
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if not an admin but is a hyper-v admin" do
|
it "returns true if not an admin but is a hyper-v admin" do
|
||||||
platform.stub(windows_admin?: false)
|
allow(platform).to receive(:windows_admin?).and_return(false)
|
||||||
platform.stub(windows_hyperv_admin?: true)
|
allow(platform).to receive(:windows_hyperv_admin?).and_return(true)
|
||||||
expect(subject).to be_usable
|
expect(subject).to be_usable
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if powershell is not available" do
|
it "returns false if powershell is not available" do
|
||||||
powershell.stub(available?: false)
|
allow(powershell).to receive(:available?).and_return(false)
|
||||||
expect(subject).to_not be_usable
|
expect(subject).to_not be_usable
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an exception if not windows" do
|
it "raises an exception if not windows" do
|
||||||
platform.stub(windows?: false)
|
allow(platform).to receive(:windows?).and_return(false)
|
||||||
|
|
||||||
expect { subject.usable?(true) }.
|
expect { subject.usable?(true) }.
|
||||||
to raise_error(VagrantPlugins::HyperV::Errors::WindowsRequired)
|
to raise_error(VagrantPlugins::HyperV::Errors::WindowsRequired)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an exception if neither an admin nor a hyper-v admin" do
|
it "raises an exception if neither an admin nor a hyper-v admin" do
|
||||||
platform.stub(windows_admin?: false)
|
allow(platform).to receive(:windows_admin?).and_return(false)
|
||||||
platform.stub(windows_hyperv_admin?: false)
|
allow(platform).to receive(:windows_hyperv_admin?).and_return(false)
|
||||||
|
|
||||||
expect { subject.usable?(true) }.
|
expect { subject.usable?(true) }.
|
||||||
to raise_error(VagrantPlugins::HyperV::Errors::AdminRequired)
|
to raise_error(VagrantPlugins::HyperV::Errors::AdminRequired)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an exception if neither an admin nor a hyper-v admin" do
|
it "raises an exception if neither an admin nor a hyper-v admin" do
|
||||||
platform.stub(windows_admin?: false)
|
allow(platform).to receive(:windows_admin?).and_return(false)
|
||||||
platform.stub(windows_hyperv_admin?: false)
|
allow(platform).to receive(:windows_hyperv_admin?).and_return(false)
|
||||||
|
|
||||||
expect { subject.usable?(true) }.
|
expect { subject.usable?(true) }.
|
||||||
to raise_error(VagrantPlugins::HyperV::Errors::AdminRequired)
|
to raise_error(VagrantPlugins::HyperV::Errors::AdminRequired)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an exception if powershell is not available" do
|
it "raises an exception if powershell is not available" do
|
||||||
powershell.stub(available?: false)
|
allow(powershell).to receive(:available?).and_return(false)
|
||||||
|
|
||||||
expect { subject.usable?(true) }.
|
expect { subject.usable?(true) }.
|
||||||
to raise_error(VagrantPlugins::HyperV::Errors::PowerShellRequired)
|
to raise_error(VagrantPlugins::HyperV::Errors::PowerShellRequired)
|
||||||
|
@ -83,13 +83,13 @@ describe VagrantPlugins::HyperV::Provider do
|
||||||
|
|
||||||
describe "#state" do
|
describe "#state" do
|
||||||
it "returns not_created if no ID" do
|
it "returns not_created if no ID" do
|
||||||
machine.stub(id: nil)
|
allow(machine).to receive(:id).and_return(nil)
|
||||||
|
|
||||||
expect(subject.state.id).to eq(:not_created)
|
expect(subject.state.id).to eq(:not_created)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calls an action to determine the ID" do
|
it "calls an action to determine the ID" do
|
||||||
machine.stub(id: "foo")
|
allow(machine).to receive(:id).and_return("foo")
|
||||||
expect(machine).to receive(:action).with(:read_state).
|
expect(machine).to receive(:action).with(:read_state).
|
||||||
and_return({ machine_state_id: :bar })
|
and_return({ machine_state_id: :bar })
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe VagrantPlugins::ProviderVirtualBox::Action::NetworkFixIPv6 do
|
||||||
|
|
||||||
let(:machine) do
|
let(:machine) do
|
||||||
iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m|
|
iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m|
|
||||||
m.provider.stub(driver: driver)
|
allow(m.provider).to receive(:driver).and_return(driver)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ describe VagrantPlugins::ProviderVirtualBox::Action::NetworkFixIPv6 do
|
||||||
.and_return(private_network: { ip: 'fe:80::' })
|
.and_return(private_network: { ip: 'fe:80::' })
|
||||||
allow(UDPSocket).to receive(:new).with(Socket::AF_INET6)
|
allow(UDPSocket).to receive(:new).with(Socket::AF_INET6)
|
||||||
.and_return(socket)
|
.and_return(socket)
|
||||||
socket.stub(:connect)
|
allow(socket).to receive(:connect)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "only checks the interfaces associated with the VM" do
|
it "only checks the interfaces associated with the VM" do
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe VagrantPlugins::ProviderVirtualBox::Action::Network do
|
||||||
|
|
||||||
let(:machine) do
|
let(:machine) do
|
||||||
iso_env.machine(iso_env.machine_names[0], :virtualbox).tap do |m|
|
iso_env.machine(iso_env.machine_names[0], :virtualbox).tap do |m|
|
||||||
m.provider.stub(driver: driver)
|
allow(m.provider).to receive(:driver).and_return(driver)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSSettings do
|
||||||
|
|
||||||
let(:machine) do
|
let(:machine) do
|
||||||
iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m|
|
iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m|
|
||||||
m.provider.stub(driver: driver)
|
allow(m.provider).to receive(:driver).and_return(driver)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSSettings do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calls the next action in the chain" do
|
it "calls the next action in the chain" do
|
||||||
driver.stub(read_network_interfaces: {2 => {type: :hostonly, hostonly: "vmnet2"}})
|
allow(driver).to receive(:read_network_interfaces).and_return({2 => {type: :hostonly, hostonly: "vmnet2"}})
|
||||||
driver.stub(read_host_only_interfaces: [{name: "vmnet2", ip: "1.2.3.4"}])
|
allow(driver).to receive(:read_host_only_interfaces).and_return([{name: "vmnet2", ip: "1.2.3.4"}])
|
||||||
allow(driver).to receive(:read_guest_ip).with(1).and_return("2.3.4.5")
|
allow(driver).to receive(:read_guest_ip).with(1).and_return("2.3.4.5")
|
||||||
|
|
||||||
called = false
|
called = false
|
||||||
|
@ -53,16 +53,16 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSSettings do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
# We can't be on Windows, because NFS gets disabled on Windows
|
# We can't be on Windows, because NFS gets disabled on Windows
|
||||||
Vagrant::Util::Platform.stub(windows?: false)
|
allow(Vagrant::Util::Platform).to receive(:windows?).and_return(false)
|
||||||
|
|
||||||
env[:machine].config.vm.synced_folder("/host/path", "/guest/path", type: "nfs")
|
env[:machine].config.vm.synced_folder("/host/path", "/guest/path", type: "nfs")
|
||||||
env[:machine].config.finalize!
|
env[:machine].config.finalize!
|
||||||
|
|
||||||
# Stub out the stuff so it just works by default
|
# Stub out the stuff so it just works by default
|
||||||
driver.stub(read_network_interfaces: {
|
allow(driver).to receive(:read_network_interfaces).and_return({
|
||||||
2 => {type: :hostonly, hostonly: "vmnet2"},
|
2 => {type: :hostonly, hostonly: "vmnet2"},
|
||||||
})
|
})
|
||||||
driver.stub(read_host_only_interfaces: host_only_interfaces)
|
allow(driver).to receive(:read_host_only_interfaces).and_return(host_only_interfaces)
|
||||||
allow(driver).to receive(:read_guest_ip).with(1).and_return("2.3.4.5")
|
allow(driver).to receive(:read_guest_ip).with(1).and_return("2.3.4.5")
|
||||||
|
|
||||||
# override sleep to 0 so test does not take seconds
|
# override sleep to 0 so test does not take seconds
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSValidIds do
|
||||||
|
|
||||||
let(:machine) do
|
let(:machine) do
|
||||||
iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m|
|
iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m|
|
||||||
m.provider.stub(driver: driver)
|
allow(m.provider).to receive(:driver).and_return(driver)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSValidIds do
|
||||||
subject { described_class.new(app, env) }
|
subject { described_class.new(app, env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
driver.stub(read_vms: {})
|
allow(driver).to receive(:read_vms).and_return({})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calls the next action in the chain" do
|
it "calls the next action in the chain" do
|
||||||
|
@ -39,7 +39,7 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSValidIds do
|
||||||
|
|
||||||
it "sets nfs_valid_ids" do
|
it "sets nfs_valid_ids" do
|
||||||
hash = {"foo" => "1", "bar" => "4"}
|
hash = {"foo" => "1", "bar" => "4"}
|
||||||
driver.stub(read_vms: hash)
|
allow(driver).to receive(:read_vms).and_return(hash)
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ describe VagrantPlugins::ProviderVirtualBox::Cap do
|
||||||
|
|
||||||
let(:machine) do
|
let(:machine) do
|
||||||
iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m|
|
iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m|
|
||||||
m.provider.stub(driver: driver)
|
allow(m.provider).to receive(:driver).and_return(driver)
|
||||||
m.stub(state: state)
|
allow(m).to receive(:state).and_return(state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,10 @@ describe VagrantPlugins::ProviderVirtualBox::Config do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
vm_config = double("vm_config")
|
vm_config = double("vm_config")
|
||||||
vm_config.stub(networks: [])
|
allow(vm_config).to receive(:networks).and_return([])
|
||||||
config = double("config")
|
config = double("config")
|
||||||
config.stub(vm: vm_config)
|
allow(config).to receive(:vm).and_return(vm_config)
|
||||||
machine.stub(config: config)
|
allow(machine).to receive(:config).and_return(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
its "valid by default" do
|
its "valid by default" do
|
||||||
|
@ -39,10 +39,10 @@ describe VagrantPlugins::ProviderVirtualBox::Config do
|
||||||
context "defaults" do
|
context "defaults" do
|
||||||
before { subject.finalize! }
|
before { subject.finalize! }
|
||||||
|
|
||||||
it { expect(subject.check_guest_additions).to be_true }
|
it { expect(subject.check_guest_additions).to be(true) }
|
||||||
it { expect(subject.gui).to be_false }
|
it { expect(subject.gui).to be(false) }
|
||||||
it { expect(subject.name).to be_nil }
|
it { expect(subject.name).to be_nil }
|
||||||
it { expect(subject.functional_vboxsf).to be_true }
|
it { expect(subject.functional_vboxsf).to be(true) }
|
||||||
|
|
||||||
it "should have one NAT adapter" do
|
it "should have one NAT adapter" do
|
||||||
expect(subject.network_adapters).to eql({
|
expect(subject.network_adapters).to eql({
|
||||||
|
|
|
@ -7,8 +7,8 @@ require Vagrant.source_root.join("plugins/providers/virtualbox/synced_folder")
|
||||||
describe VagrantPlugins::ProviderVirtualBox::SyncedFolder do
|
describe VagrantPlugins::ProviderVirtualBox::SyncedFolder do
|
||||||
let(:machine) do
|
let(:machine) do
|
||||||
double("machine").tap do |m|
|
double("machine").tap do |m|
|
||||||
m.stub(provider_config: VagrantPlugins::ProviderVirtualBox::Config.new)
|
allow(m).to receive(:provider_config).and_return(VagrantPlugins::ProviderVirtualBox::Config.new)
|
||||||
m.stub(provider_name: :virtualbox)
|
allow(m).to receive(:provider_name).and_return(:virtualbox)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,12 +20,12 @@ describe VagrantPlugins::ProviderVirtualBox::SyncedFolder do
|
||||||
|
|
||||||
describe "usable" do
|
describe "usable" do
|
||||||
it "should be with virtualbox provider" do
|
it "should be with virtualbox provider" do
|
||||||
machine.stub(provider_name: :virtualbox)
|
allow(machine).to receive(:provider_name).and_return(:virtualbox)
|
||||||
expect(subject).to be_usable(machine)
|
expect(subject).to be_usable(machine)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not be with another provider" do
|
it "should not be with another provider" do
|
||||||
machine.stub(provider_name: :vmware_fusion)
|
allow(machine).to receive(:provider_name).and_return(:vmware_fusion)
|
||||||
expect(subject).not_to be_usable(machine)
|
expect(subject).not_to be_usable(machine)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,11 +39,9 @@ describe VagrantPlugins::ProviderVirtualBox::SyncedFolder do
|
||||||
let(:driver) { double("driver") }
|
let(:driver) { double("driver") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(driver: driver)
|
allow(machine).to receive(:driver).and_return(driver)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should share the folders" do
|
it "should share the folders"
|
||||||
pending
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,7 +51,7 @@ describe VagrantPlugins::Ansible::Config::Guest do
|
||||||
it "assigns default values to unset guest-specific options" do
|
it "assigns default values to unset guest-specific options" do
|
||||||
subject.finalize!
|
subject.finalize!
|
||||||
|
|
||||||
expect(subject.install).to be_true
|
expect(subject.install).to be(true)
|
||||||
expect(subject.install_mode).to eql(:default)
|
expect(subject.install_mode).to eql(:default)
|
||||||
expect(subject.provisioning_path).to eql("/vagrant")
|
expect(subject.provisioning_path).to eql("/vagrant")
|
||||||
expect(subject.tmp_path).to eql("/tmp/vagrant-ansible")
|
expect(subject.tmp_path).to eql("/tmp/vagrant-ansible")
|
||||||
|
|
|
@ -47,10 +47,10 @@ describe VagrantPlugins::Ansible::Config::Host, :skip_windows => true do
|
||||||
it "assigns default values to unset host-specific options" do
|
it "assigns default values to unset host-specific options" do
|
||||||
subject.finalize!
|
subject.finalize!
|
||||||
|
|
||||||
expect(subject.ask_sudo_pass).to be_false
|
expect(subject.ask_sudo_pass).to be(false)
|
||||||
expect(subject.ask_vault_pass).to be_false
|
expect(subject.ask_vault_pass).to be(false)
|
||||||
expect(subject.force_remote_user).to be_true
|
expect(subject.force_remote_user).to be(true)
|
||||||
expect(subject.host_key_checking).to be_false
|
expect(subject.host_key_checking).to be(false)
|
||||||
expect(subject.raw_ssh_args).to be_nil
|
expect(subject.raw_ssh_args).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,11 +17,11 @@ shared_examples_for 'options shared by both Ansible provisioners' do
|
||||||
expect(subject.raw_arguments).to be_nil
|
expect(subject.raw_arguments).to be_nil
|
||||||
expect(subject.skip_tags).to be_nil
|
expect(subject.skip_tags).to be_nil
|
||||||
expect(subject.start_at_task).to be_nil
|
expect(subject.start_at_task).to be_nil
|
||||||
expect(subject.sudo).to be_false
|
expect(subject.sudo).to be(false)
|
||||||
expect(subject.sudo_user).to be_nil
|
expect(subject.sudo_user).to be_nil
|
||||||
expect(subject.tags).to be_nil
|
expect(subject.tags).to be_nil
|
||||||
expect(subject.vault_password_file).to be_nil
|
expect(subject.vault_password_file).to be_nil
|
||||||
expect(subject.verbose).to be_false
|
expect(subject.verbose).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,20 +45,22 @@ VF
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
port: 2223
|
port: 2223
|
||||||
}}
|
}}
|
||||||
|
let(:default_execute_result) { Vagrant::Util::Subprocess::Result.new(0, "", "") }
|
||||||
|
|
||||||
let(:existing_file) { File.expand_path(__FILE__) }
|
let(:existing_file) { File.expand_path(__FILE__) }
|
||||||
let(:generated_inventory_dir) { File.join(machine.env.local_data_path, %w(provisioners ansible inventory)) }
|
let(:generated_inventory_dir) { File.join(machine.env.local_data_path, %w(provisioners ansible inventory)) }
|
||||||
let(:generated_inventory_file) { File.join(generated_inventory_dir, 'vagrant_ansible_inventory') }
|
let(:generated_inventory_file) { File.join(generated_inventory_dir, 'vagrant_ansible_inventory') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant::Util::Platform.stub(solaris?: false)
|
allow(Vagrant::Util::Platform).to receive(:solaris?).and_return(false)
|
||||||
|
|
||||||
machine.stub(ssh_info: ssh_info)
|
allow(machine).to receive(:ssh_info).and_return(ssh_info)
|
||||||
machine.env.stub(active_machines: [[iso_env.machine_names[0], :dummy], [iso_env.machine_names[1], :dummy]])
|
allow(machine.env).to receive(:active_machines)
|
||||||
|
.and_return([[iso_env.machine_names[0], :dummy], [iso_env.machine_names[1], :dummy]])
|
||||||
|
|
||||||
stubbed_ui = Vagrant::UI::Colored.new
|
stubbed_ui = Vagrant::UI::Colored.new
|
||||||
stubbed_ui.stub(detail: "")
|
allow(stubbed_ui).to receive(:detail).and_return("")
|
||||||
machine.env.stub(ui: stubbed_ui)
|
allow(machine.env).to receive(:ui).and_return(stubbed_ui)
|
||||||
|
|
||||||
config.playbook = 'playbook.yml'
|
config.playbook = 'playbook.yml'
|
||||||
end
|
end
|
||||||
|
@ -74,7 +76,7 @@ VF
|
||||||
expected_transport_mode = "ssh")
|
expected_transport_mode = "ssh")
|
||||||
|
|
||||||
it "sets implicit arguments in a specific order" do
|
it "sets implicit arguments in a specific order" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
|
|
||||||
expect(args[0]).to eq("ansible-playbook")
|
expect(args[0]).to eq("ansible-playbook")
|
||||||
expect(args[1]).to eq("--connection=ssh")
|
expect(args[1]).to eq("--connection=ssh")
|
||||||
|
@ -84,11 +86,11 @@ VF
|
||||||
expect(inventory_count).to be > 0
|
expect(inventory_count).to be > 0
|
||||||
|
|
||||||
expect(args[args.length-2]).to eq("playbook.yml")
|
expect(args[args.length-2]).to eq("playbook.yml")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets --limit argument" do
|
it "sets --limit argument" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
all_limits = args.select { |x| x =~ /^(--limit=|-l)/ }
|
all_limits = args.select { |x| x =~ /^(--limit=|-l)/ }
|
||||||
if config.raw_arguments
|
if config.raw_arguments
|
||||||
raw_limits = config.raw_arguments.select { |x| x =~ /^(--limit=|-l)/ }
|
raw_limits = config.raw_arguments.select { |x| x =~ /^(--limit=|-l)/ }
|
||||||
|
@ -102,11 +104,11 @@ VF
|
||||||
expect(all_limits.first).to eq("--limit=#{machine.name}")
|
expect(all_limits.first).to eq("--limit=#{machine.name}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "exports environment variables" do
|
it "exports environment variables" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
|
|
||||||
if expected_host_key_checking
|
if expected_host_key_checking
|
||||||
|
@ -119,30 +121,30 @@ VF
|
||||||
expect(cmd_opts[:env]).to_not include("ANSIBLE_NOCOLOR")
|
expect(cmd_opts[:env]).to_not include("ANSIBLE_NOCOLOR")
|
||||||
expect(cmd_opts[:env]['ANSIBLE_HOST_KEY_CHECKING']).to eql(expected_host_key_checking.to_s)
|
expect(cmd_opts[:env]['ANSIBLE_HOST_KEY_CHECKING']).to eql(expected_host_key_checking.to_s)
|
||||||
expect(cmd_opts[:env]['PYTHONUNBUFFERED']).to eql(1)
|
expect(cmd_opts[:env]['PYTHONUNBUFFERED']).to eql(1)
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
# "roughly" verify that only expected args/vars have been defined by the provisioner
|
# "roughly" verify that only expected args/vars have been defined by the provisioner
|
||||||
it "sets the expected number of arguments and environment variables" do
|
it "sets the expected number of arguments and environment variables" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args.length-2).to eq(expected_args_count)
|
expect(args.length-2).to eq(expected_args_count)
|
||||||
expect(args.last[:env].length).to eq(expected_vars_count)
|
expect(args.last[:env].length).to eq(expected_vars_count)
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "enables '#{expected_transport_mode}' as default transport mode" do
|
it "enables '#{expected_transport_mode}' as default transport mode" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
index = args.rindex("--connection=#{expected_transport_mode}")
|
index = args.rindex("--connection=#{expected_transport_mode}")
|
||||||
expect(index).to be > 0
|
expect(index).to be > 0
|
||||||
expect(find_last_argument_after(index, args, /--connection=\w+/)).to be_false
|
expect(find_last_argument_after(index, args, /--connection=\w+/)).to be(false)
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.it_should_set_optional_arguments(arg_map)
|
def self.it_should_set_optional_arguments(arg_map)
|
||||||
it "sets optional arguments" do
|
it "sets optional arguments" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
arg_map.each_pair do |vagrant_option, ansible_argument|
|
arg_map.each_pair do |vagrant_option, ansible_argument|
|
||||||
index = args.index(ansible_argument)
|
index = args.index(ansible_argument)
|
||||||
if config.send(vagrant_option)
|
if config.send(vagrant_option)
|
||||||
|
@ -151,25 +153,25 @@ VF
|
||||||
expect(index).to be_nil
|
expect(index).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.it_should_explicitly_enable_ansible_ssh_control_persist_defaults
|
def self.it_should_explicitly_enable_ansible_ssh_control_persist_defaults
|
||||||
it "configures ControlPersist (like Ansible defaults) via ANSIBLE_SSH_ARGS" do
|
it "configures ControlPersist (like Ansible defaults) via ANSIBLE_SSH_ARGS" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o ControlMaster=auto")
|
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o ControlMaster=auto")
|
||||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o ControlPersist=60s")
|
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o ControlPersist=60s")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.it_should_create_and_use_generated_inventory(with_ssh_user = true)
|
def self.it_should_create_and_use_generated_inventory(with_ssh_user = true)
|
||||||
it "generates an inventory with all active machines" do
|
it "generates an inventory with all active machines" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(config.inventory_path).to be_nil
|
expect(config.inventory_path).to be_nil
|
||||||
expect(File.exists?(generated_inventory_file)).to be_true
|
expect(File.exists?(generated_inventory_file)).to be(true)
|
||||||
inventory_content = File.read(generated_inventory_file)
|
inventory_content = File.read(generated_inventory_file)
|
||||||
if with_ssh_user
|
if with_ssh_user
|
||||||
expect(inventory_content).to include("#{machine.name} ansible_ssh_host=#{machine.ssh_info[:host]} ansible_ssh_port=#{machine.ssh_info[:port]} ansible_ssh_user='#{machine.ssh_info[:username]}' ansible_ssh_private_key_file='#{machine.ssh_info[:private_key_path][0]}'\n")
|
expect(inventory_content).to include("#{machine.name} ansible_ssh_host=#{machine.ssh_info[:host]} ansible_ssh_port=#{machine.ssh_info[:port]} ansible_ssh_user='#{machine.ssh_info[:username]}' ansible_ssh_private_key_file='#{machine.ssh_info[:private_key_path][0]}'\n")
|
||||||
|
@ -177,31 +179,32 @@ VF
|
||||||
expect(inventory_content).to include("#{machine.name} ansible_ssh_host=#{machine.ssh_info[:host]} ansible_ssh_port=#{machine.ssh_info[:port]} ansible_ssh_private_key_file='#{machine.ssh_info[:private_key_path][0]}'\n")
|
expect(inventory_content).to include("#{machine.name} ansible_ssh_host=#{machine.ssh_info[:host]} ansible_ssh_port=#{machine.ssh_info[:port]} ansible_ssh_private_key_file='#{machine.ssh_info[:private_key_path][0]}'\n")
|
||||||
end
|
end
|
||||||
expect(inventory_content).to include("# MISSING: '#{iso_env.machine_names[1]}' machine was probably removed without using Vagrant. This machine should be recreated.\n")
|
expect(inventory_content).to include("# MISSING: '#{iso_env.machine_names[1]}' machine was probably removed without using Vagrant. This machine should be recreated.\n")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets as ansible inventory the directory containing the auto-generated inventory file" do
|
it "sets as ansible inventory the directory containing the auto-generated inventory file" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
inventory_index = args.rindex("--inventory-file=#{generated_inventory_dir}")
|
inventory_index = args.rindex("--inventory-file=#{generated_inventory_dir}")
|
||||||
expect(inventory_index).to be > 0
|
expect(inventory_index).to be > 0
|
||||||
expect(find_last_argument_after(inventory_index, args, /--inventory-file=\w+/)).to be_false
|
expect(find_last_argument_after(inventory_index, args, /--inventory-file=\w+/)).to be(false)
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#provision" do
|
describe "#provision" do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
unless example.metadata[:skip_before]
|
unless RSpec.current_example.metadata[:skip_before]
|
||||||
config.finalize!
|
config.finalize!
|
||||||
|
|
||||||
Vagrant::Util::Subprocess.stub(execute: Vagrant::Util::Subprocess::Result.new(0, "", ""))
|
allow(Vagrant::Util::Subprocess).to receive(:execute)
|
||||||
subject.stub(:check_path)
|
.and_return(Vagrant::Util::Subprocess::Result.new(0, "", ""))
|
||||||
|
allow(subject).to receive(:check_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
unless example.metadata[:skip_after]
|
unless RSpec.current_example.metadata[:skip_after]
|
||||||
subject.provision
|
subject.provision
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -211,7 +214,7 @@ VF
|
||||||
STUBBED_INVALID_PATH = "/test/239nfmd/invalid_path".freeze
|
STUBBED_INVALID_PATH = "/test/239nfmd/invalid_path".freeze
|
||||||
|
|
||||||
it 'raises an error when the `playbook` file does not exist', skip_before: true, skip_after: true do
|
it 'raises an error when the `playbook` file does not exist', skip_before: true, skip_after: true do
|
||||||
subject.stub(:check_path).and_raise(VagrantPlugins::Ansible::Errors::AnsibleError,
|
allow(subject).to receive(:check_path).and_raise(VagrantPlugins::Ansible::Errors::AnsibleError,
|
||||||
_key: :config_file_not_found,
|
_key: :config_file_not_found,
|
||||||
config_option: "playbook",
|
config_option: "playbook",
|
||||||
path: STUBBED_INVALID_PATH,
|
path: STUBBED_INVALID_PATH,
|
||||||
|
@ -226,7 +229,8 @@ VF
|
||||||
|
|
||||||
%w(config_file extra_vars inventory_path galaxy_role_file vault_password_file).each do |option_name|
|
%w(config_file extra_vars inventory_path galaxy_role_file vault_password_file).each do |option_name|
|
||||||
it "raises an error when the '#{option_name}' does not exist", skip_before: true, skip_after: true do
|
it "raises an error when the '#{option_name}' does not exist", skip_before: true, skip_after: true do
|
||||||
Vagrant::Util::Subprocess.stub(execute: Vagrant::Util::Subprocess::Result.new(0, "", ""))
|
allow(Vagrant::Util::Subprocess).to receive(:execute)
|
||||||
|
.and_return( Vagrant::Util::Subprocess::Result.new(0, "", ""))
|
||||||
|
|
||||||
config.playbook = existing_file
|
config.playbook = existing_file
|
||||||
config.send(option_name + '=', STUBBED_INVALID_PATH)
|
config.send(option_name + '=', STUBBED_INVALID_PATH)
|
||||||
|
@ -247,8 +251,8 @@ VF
|
||||||
it "raises an error", skip_before: true, skip_after: true do
|
it "raises an error", skip_before: true, skip_after: true do
|
||||||
config.finalize!
|
config.finalize!
|
||||||
|
|
||||||
subject.stub(:check_path)
|
allow(subject).to receive(:check_path)
|
||||||
Vagrant::Util::Subprocess.stub(execute: Vagrant::Util::Subprocess::Result.new(1, "", ""))
|
allow(Vagrant::Util::Subprocess).to receive(:execute).and_return(Vagrant::Util::Subprocess::Result.new(1, "", ""))
|
||||||
|
|
||||||
expect {subject.provision}.to raise_error(VagrantPlugins::Ansible::Errors::AnsibleCommandFailed)
|
expect {subject.provision}.to raise_error(VagrantPlugins::Ansible::Errors::AnsibleCommandFailed)
|
||||||
end
|
end
|
||||||
|
@ -259,18 +263,14 @@ VF
|
||||||
it_should_create_and_use_generated_inventory
|
it_should_create_and_use_generated_inventory
|
||||||
|
|
||||||
it "does not add any group section to the generated inventory" do
|
it "does not add any group section to the generated inventory" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
inventory_content = File.read(generated_inventory_file)
|
inventory_content = File.read(generated_inventory_file)
|
||||||
expect(inventory_content).to_not match(/^\s*\[^\\+\]\s*$/)
|
expect(inventory_content).to_not match(/^\s*\[^\\+\]\s*$/)
|
||||||
|
}.and_return(default_execute_result)
|
||||||
# Ending this block with a negative expectation (to_not / not_to)
|
|
||||||
# would lead to a failure of the above expectation.
|
|
||||||
true
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't show the ansible-playbook command" do
|
it "doesn't show the ansible-playbook command" do
|
||||||
expect(machine.env.ui).not_to receive(:detail).with { |full_command|
|
expect(machine.env.ui).not_to receive(:detail).with(any_args) { |full_command|
|
||||||
expect(full_command).to include("ansible-playbook")
|
expect(full_command).to include("ansible-playbook")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -282,9 +282,9 @@ VF
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses custom playbook_command to run playbooks" do
|
it "uses custom playbook_command to run playbooks" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args[0]).to eq("custom-ansible-playbook")
|
expect(args[0]).to eq("custom-ansible-playbook")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -295,40 +295,40 @@ VF
|
||||||
config.host_vars = {
|
config.host_vars = {
|
||||||
machine1: {"http_port" => 80, "comments" => "'some text with spaces'"}
|
machine1: {"http_port" => 80, "comments" => "'some text with spaces'"}
|
||||||
}
|
}
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
inventory_content = File.read(generated_inventory_file)
|
inventory_content = File.read(generated_inventory_file)
|
||||||
expect(inventory_content).to match("^" + Regexp.quote(machine.name) + ".+http_port=80 comments='some text with spaces'$")
|
expect(inventory_content).to match("^" + Regexp.quote(machine.name) + ".+http_port=80 comments='some text with spaces'$")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds host variables (given in Array format) to the generated inventory" do
|
it "adds host variables (given in Array format) to the generated inventory" do
|
||||||
config.host_vars = {
|
config.host_vars = {
|
||||||
machine1: ["http_port=80", "maxRequestsPerChild=808"]
|
machine1: ["http_port=80", "maxRequestsPerChild=808"]
|
||||||
}
|
}
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
inventory_content = File.read(generated_inventory_file)
|
inventory_content = File.read(generated_inventory_file)
|
||||||
expect(inventory_content).to match("^" + Regexp.quote(machine.name) + ".+http_port=80 maxRequestsPerChild=808")
|
expect(inventory_content).to match("^" + Regexp.quote(machine.name) + ".+http_port=80 maxRequestsPerChild=808")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds host variables (given in String format) to the generated inventory " do
|
it "adds host variables (given in String format) to the generated inventory " do
|
||||||
config.host_vars = {
|
config.host_vars = {
|
||||||
:machine1 => "http_port=80 maxRequestsPerChild=808"
|
:machine1 => "http_port=80 maxRequestsPerChild=808"
|
||||||
}
|
}
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
inventory_content = File.read(generated_inventory_file)
|
inventory_content = File.read(generated_inventory_file)
|
||||||
expect(inventory_content).to match("^" + Regexp.quote(machine.name) + ".+http_port=80 maxRequestsPerChild=808")
|
expect(inventory_content).to match("^" + Regexp.quote(machine.name) + ".+http_port=80 maxRequestsPerChild=808")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "retrieves the host variables by machine name, also in String format" do
|
it "retrieves the host variables by machine name, also in String format" do
|
||||||
config.host_vars = {
|
config.host_vars = {
|
||||||
"machine1" => "http_port=80 maxRequestsPerChild=808"
|
"machine1" => "http_port=80 maxRequestsPerChild=808"
|
||||||
}
|
}
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
inventory_content = File.read(generated_inventory_file)
|
inventory_content = File.read(generated_inventory_file)
|
||||||
expect(inventory_content).to match("^" + Regexp.quote(machine.name) + ".+http_port=80 maxRequestsPerChild=808")
|
expect(inventory_content).to match("^" + Regexp.quote(machine.name) + ".+http_port=80 maxRequestsPerChild=808")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ VF
|
||||||
"bar:children" => ["group1", "group2", "group3", "group5"],
|
"bar:children" => ["group1", "group2", "group3", "group5"],
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
inventory_content = File.read(generated_inventory_file)
|
inventory_content = File.read(generated_inventory_file)
|
||||||
|
|
||||||
# Accept String instead of Array for group member list
|
# Accept String instead of Array for group member list
|
||||||
|
@ -372,7 +372,7 @@ VF
|
||||||
# A group of groups only includes declared groups
|
# A group of groups only includes declared groups
|
||||||
expect(inventory_content).not_to include("group5")
|
expect(inventory_content).not_to include("group5")
|
||||||
expect(inventory_content).to match(Regexp.quote("[bar:children]\ngroup1\ngroup2\ngroup3\n") + "$")
|
expect(inventory_content).to match(Regexp.quote("[bar:children]\ngroup1\ngroup2\ngroup3\n") + "$")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds group vars to the generated inventory" do
|
it "adds group vars to the generated inventory" do
|
||||||
|
@ -385,7 +385,7 @@ VF
|
||||||
"group3:vars" => "stringvar1=stringvalue1 stringvar2=stringvalue2",
|
"group3:vars" => "stringvar1=stringvalue1 stringvar2=stringvalue2",
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
inventory_content = File.read(generated_inventory_file)
|
inventory_content = File.read(generated_inventory_file)
|
||||||
|
|
||||||
# Hash syntax
|
# Hash syntax
|
||||||
|
@ -396,7 +396,7 @@ VF
|
||||||
|
|
||||||
# Single string syntax
|
# Single string syntax
|
||||||
expect(inventory_content).to include("[group3:vars]\nstringvar1=stringvalue1\nstringvar2=stringvalue2\n")
|
expect(inventory_content).to include("[group3:vars]\nstringvar1=stringvalue1\nstringvar2=stringvalue2\n")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -421,11 +421,11 @@ VF
|
||||||
it_should_set_optional_arguments({ "sudo_user" => "--sudo-user=root" })
|
it_should_set_optional_arguments({ "sudo_user" => "--sudo-user=root" })
|
||||||
|
|
||||||
it "it does not set boolean flag when corresponding option is set to false" do
|
it "it does not set boolean flag when corresponding option is set to false" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args.index("--sudo")).to be_nil
|
expect(args.index("--sudo")).to be_nil
|
||||||
expect(args.index("--ask-sudo-pass")).to be_nil
|
expect(args.index("--ask-sudo-pass")).to be_nil
|
||||||
expect(args.index("--ask-vault-pass")).to be_nil
|
expect(args.index("--ask-vault-pass")).to be_nil
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -450,26 +450,26 @@ VF
|
||||||
it_should_set_arguments_and_environment_variables 17, 4, false, "paramiko"
|
it_should_set_arguments_and_environment_variables 17, 4, false, "paramiko"
|
||||||
|
|
||||||
it "sets all raw arguments" do
|
it "sets all raw arguments" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
config.raw_arguments.each do |raw_arg|
|
config.raw_arguments.each do |raw_arg|
|
||||||
expect(args).to include(raw_arg)
|
expect(args).to include(raw_arg)
|
||||||
end
|
end
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets raw arguments after arguments related to supported options" do
|
it "sets raw arguments after arguments related to supported options" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args.index("--user=lion")).to be > args.index("--user=testuser")
|
expect(args.index("--user=lion")).to be > args.index("--user=testuser")
|
||||||
expect(args.index("--inventory-file=/forget/it/my/friend")).to be > args.index("--inventory-file=#{generated_inventory_dir}")
|
expect(args.index("--inventory-file=/forget/it/my/friend")).to be > args.index("--inventory-file=#{generated_inventory_dir}")
|
||||||
expect(args.index("--limit=bar")).to be > args.index("--limit=all")
|
expect(args.index("--limit=bar")).to be > args.index("--limit=all")
|
||||||
expect(args.index("--skip-tags=ignored")).to be > args.index("--skip-tags=foo,bar")
|
expect(args.index("--skip-tags=ignored")).to be > args.index("--skip-tags=foo,bar")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets boolean flag (e.g. --sudo) defined in raw_arguments, even if corresponding option is set to false" do
|
it "sets boolean flag (e.g. --sudo) defined in raw_arguments, even if corresponding option is set to false" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args).to include('--sudo')
|
expect(args).to include('--sudo')
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -492,10 +492,10 @@ VF
|
||||||
it_should_set_arguments_and_environment_variables 6
|
it_should_set_arguments_and_environment_variables 6
|
||||||
|
|
||||||
it "uses a --user argument to set a default remote user" do
|
it "uses a --user argument to set a default remote user" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args).not_to include("--extra-vars=ansible_ssh_user='#{machine.ssh_info[:username]}'")
|
expect(args).not_to include("--extra-vars=ansible_ssh_user='#{machine.ssh_info[:username]}'")
|
||||||
expect(args).to include("--user=#{machine.ssh_info[:username]}")
|
expect(args).to include("--user=#{machine.ssh_info[:username]}")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -524,13 +524,13 @@ VF
|
||||||
|
|
||||||
it "generates an inventory with winrm connection settings" do
|
it "generates an inventory with winrm connection settings" do
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(config.inventory_path).to be_nil
|
expect(config.inventory_path).to be_nil
|
||||||
expect(File.exists?(generated_inventory_file)).to be_true
|
expect(File.exists?(generated_inventory_file)).to be(true)
|
||||||
inventory_content = File.read(generated_inventory_file)
|
inventory_content = File.read(generated_inventory_file)
|
||||||
|
|
||||||
expect(inventory_content).to include("machine1 ansible_connection=winrm ansible_ssh_host=127.0.0.1 ansible_ssh_port=55986 ansible_ssh_user='winner' ansible_ssh_pass='winword'\n")
|
expect(inventory_content).to include("machine1 ansible_connection=winrm ansible_ssh_host=127.0.0.1 ansible_ssh_port=55986 ansible_ssh_user='winner' ansible_ssh_pass='winword'\n")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with force_remote_user option disabled" do
|
describe "with force_remote_user option disabled" do
|
||||||
|
@ -539,12 +539,12 @@ VF
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't set the ansible remote user in inventory and use '--user' argument with the vagrant ssh username" do
|
it "doesn't set the ansible remote user in inventory and use '--user' argument with the vagrant ssh username" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
inventory_content = File.read(generated_inventory_file)
|
inventory_content = File.read(generated_inventory_file)
|
||||||
|
|
||||||
expect(inventory_content).to include("machine1 ansible_connection=winrm ansible_ssh_host=127.0.0.1 ansible_ssh_port=55986 ansible_ssh_pass='winword'\n")
|
expect(inventory_content).to include("machine1 ansible_connection=winrm ansible_ssh_host=127.0.0.1 ansible_ssh_port=55986 ansible_ssh_pass='winword'\n")
|
||||||
expect(args).to include("--user=testuser")
|
expect(args).to include("--user=testuser")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -557,18 +557,18 @@ VF
|
||||||
it_should_set_arguments_and_environment_variables 6
|
it_should_set_arguments_and_environment_variables 6
|
||||||
|
|
||||||
it "does not generate the inventory and uses given inventory path instead" do
|
it "does not generate the inventory and uses given inventory path instead" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args).to include("--inventory-file=#{existing_file}")
|
expect(args).to include("--inventory-file=#{existing_file}")
|
||||||
expect(args).not_to include("--inventory-file=#{generated_inventory_file}")
|
expect(args).not_to include("--inventory-file=#{generated_inventory_file}")
|
||||||
expect(File.exists?(generated_inventory_file)).to be_false
|
expect(File.exists?(generated_inventory_file)).to be(false)
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses an --extra-vars argument to force ansible_ssh_user parameter" do
|
it "uses an --extra-vars argument to force ansible_ssh_user parameter" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args).not_to include("--user=#{machine.ssh_info[:username]}")
|
expect(args).not_to include("--user=#{machine.ssh_info[:username]}")
|
||||||
expect(args).to include("--extra-vars=ansible_ssh_user='#{machine.ssh_info[:username]}'")
|
expect(args).to include("--extra-vars=ansible_ssh_user='#{machine.ssh_info[:username]}'")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with force_remote_user option disabled" do
|
describe "with force_remote_user option disabled" do
|
||||||
|
@ -577,10 +577,10 @@ VF
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses a --user argument to set a default remote user" do
|
it "uses a --user argument to set a default remote user" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args).not_to include("--extra-vars=ansible_ssh_user='#{machine.ssh_info[:username]}'")
|
expect(args).not_to include("--extra-vars=ansible_ssh_user='#{machine.ssh_info[:username]}'")
|
||||||
expect(args).to include("--user=#{machine.ssh_info[:username]}")
|
expect(args).to include("--user=#{machine.ssh_info[:username]}")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -591,11 +591,11 @@ VF
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets ANSIBLE_CONFIG environment variable" do
|
it "sets ANSIBLE_CONFIG environment variable" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]).to include("ANSIBLE_CONFIG")
|
expect(cmd_opts[:env]).to include("ANSIBLE_CONFIG")
|
||||||
expect(cmd_opts[:env]['ANSIBLE_CONFIG']).to eql(existing_file)
|
expect(cmd_opts[:env]['ANSIBLE_CONFIG']).to eql(existing_file)
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -607,9 +607,9 @@ VF
|
||||||
it_should_set_arguments_and_environment_variables 6
|
it_should_set_arguments_and_environment_variables 6
|
||||||
|
|
||||||
it "should ask the vault password" do
|
it "should ask the vault password" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args).to include("--ask-vault-pass")
|
expect(args).to include("--ask-vault-pass")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -621,9 +621,9 @@ VF
|
||||||
it_should_set_arguments_and_environment_variables 6
|
it_should_set_arguments_and_environment_variables 6
|
||||||
|
|
||||||
it "uses the given vault password file" do
|
it "uses the given vault password file" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args).to include("--vault-password-file=#{existing_file}")
|
expect(args).to include("--vault-password-file=#{existing_file}")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -636,12 +636,12 @@ VF
|
||||||
it_should_explicitly_enable_ansible_ssh_control_persist_defaults
|
it_should_explicitly_enable_ansible_ssh_control_persist_defaults
|
||||||
|
|
||||||
it "passes custom SSH options via ANSIBLE_SSH_ARGS with the highest priority" do
|
it "passes custom SSH options via ANSIBLE_SSH_ARGS with the highest priority" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
raw_opt_index = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ControlMaster=no")
|
raw_opt_index = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ControlMaster=no")
|
||||||
default_opt_index = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ControlMaster=auto")
|
default_opt_index = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ControlMaster=auto")
|
||||||
expect(raw_opt_index).to be < default_opt_index
|
expect(raw_opt_index).to be < default_opt_index
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "and with ssh forwarding enabled" do
|
describe "and with ssh forwarding enabled" do
|
||||||
|
@ -650,12 +650,12 @@ VF
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets '-o ForwardAgent=yes' via ANSIBLE_SSH_ARGS with higher priority than raw_ssh_args values" do
|
it "sets '-o ForwardAgent=yes' via ANSIBLE_SSH_ARGS with higher priority than raw_ssh_args values" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
forwardAgentYes = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ForwardAgent=yes")
|
forwardAgentYes = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ForwardAgent=yes")
|
||||||
forwardAgentNo = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ForwardAgent=no")
|
forwardAgentNo = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ForwardAgent=no")
|
||||||
expect(forwardAgentYes).to be < forwardAgentNo
|
expect(forwardAgentYes).to be < forwardAgentNo
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -670,11 +670,11 @@ VF
|
||||||
it_should_explicitly_enable_ansible_ssh_control_persist_defaults
|
it_should_explicitly_enable_ansible_ssh_control_persist_defaults
|
||||||
|
|
||||||
it "passes additional Identity Files via ANSIBLE_SSH_ARGS" do
|
it "passes additional Identity Files via ANSIBLE_SSH_ARGS" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o IdentityFile=/an/other/identity")
|
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o IdentityFile=/an/other/identity")
|
||||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o IdentityFile=/yet/an/other/key")
|
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o IdentityFile=/yet/an/other/key")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -684,11 +684,11 @@ VF
|
||||||
end
|
end
|
||||||
|
|
||||||
it "replaces `%` with `%%`" do
|
it "replaces `%` with `%%`" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o IdentityFile=/foo%%bar/key")
|
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o IdentityFile=/foo%%bar/key")
|
||||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o IdentityFile=/bar%%%%buz/key")
|
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o IdentityFile=/bar%%%%buz/key")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -701,10 +701,10 @@ VF
|
||||||
it_should_explicitly_enable_ansible_ssh_control_persist_defaults
|
it_should_explicitly_enable_ansible_ssh_control_persist_defaults
|
||||||
|
|
||||||
it "enables SSH-Forwarding via ANSIBLE_SSH_ARGS" do
|
it "enables SSH-Forwarding via ANSIBLE_SSH_ARGS" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o ForwardAgent=yes")
|
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o ForwardAgent=yes")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -714,10 +714,10 @@ VF
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets '-o ProxyCommand' via ANSIBLE_SSH_ARGS" do
|
it "sets '-o ProxyCommand' via ANSIBLE_SSH_ARGS" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o ProxyCommand='ssh -W %h:%p -q user@remote_libvirt_host'")
|
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o ProxyCommand='ssh -W %h:%p -q user@remote_libvirt_host'")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -733,7 +733,7 @@ VF
|
||||||
it_should_set_optional_arguments({ "verbose" => "-#{verbose_option}" })
|
it_should_set_optional_arguments({ "verbose" => "-#{verbose_option}" })
|
||||||
|
|
||||||
it "shows the ansible-playbook command and set verbosity to '-#{verbose_option}' level" do
|
it "shows the ansible-playbook command and set verbosity to '-#{verbose_option}' level" do
|
||||||
expect(machine.env.ui).to receive(:detail).with { |full_command|
|
expect(machine.env.ui).to receive(:detail).with(any_args) { |full_command|
|
||||||
expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --limit=\"machine1\" --inventory-file=#{generated_inventory_dir} -#{verbose_option} playbook.yml")
|
expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --limit=\"machine1\" --inventory-file=#{generated_inventory_dir} -#{verbose_option} playbook.yml")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -748,7 +748,7 @@ VF
|
||||||
it_should_set_optional_arguments({ "verbose" => "-#{verbose_option}" })
|
it_should_set_optional_arguments({ "verbose" => "-#{verbose_option}" })
|
||||||
|
|
||||||
it "shows the ansible-playbook command and set verbosity to '-#{verbose_option}' level" do
|
it "shows the ansible-playbook command and set verbosity to '-#{verbose_option}' level" do
|
||||||
expect(machine.env.ui).to receive(:detail).with { |full_command|
|
expect(machine.env.ui).to receive(:detail).with(any_args) { |full_command|
|
||||||
expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --limit=\"machine1\" --inventory-file=#{generated_inventory_dir} -#{verbose_option} playbook.yml")
|
expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --limit=\"machine1\" --inventory-file=#{generated_inventory_dir} -#{verbose_option} playbook.yml")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -764,7 +764,7 @@ VF
|
||||||
it_should_set_optional_arguments({ "verbose" => "-v" })
|
it_should_set_optional_arguments({ "verbose" => "-v" })
|
||||||
|
|
||||||
it "shows the ansible-playbook command and set verbosity to '-v' level" do
|
it "shows the ansible-playbook command and set verbosity to '-v' level" do
|
||||||
expect(machine.env.ui).to receive(:detail).with { |full_command|
|
expect(machine.env.ui).to receive(:detail).with(any_args) { |full_command|
|
||||||
expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --limit=\"machine1\" --inventory-file=#{generated_inventory_dir} -v playbook.yml")
|
expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --limit=\"machine1\" --inventory-file=#{generated_inventory_dir} -v playbook.yml")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -778,7 +778,7 @@ VF
|
||||||
it_should_set_arguments_and_environment_variables
|
it_should_set_arguments_and_environment_variables
|
||||||
|
|
||||||
it "doesn't show the ansible-playbook command" do
|
it "doesn't show the ansible-playbook command" do
|
||||||
expect(machine.env.ui).not_to receive(:detail).with { |full_command|
|
expect(machine.env.ui).not_to receive(:detail).with(any_args) { |full_command|
|
||||||
expect(full_command).to include("ansible-playbook")
|
expect(full_command).to include("ansible-playbook")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -788,15 +788,15 @@ VF
|
||||||
|
|
||||||
describe "without colorized output" do
|
describe "without colorized output" do
|
||||||
before do
|
before do
|
||||||
machine.env.stub(ui: Vagrant::UI::Basic.new)
|
allow(machine.env).to receive(:ui).and_return(Vagrant::UI::Basic.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "disables ansible-playbook colored output" do
|
it "disables ansible-playbook colored output" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]).to_not include("ANSIBLE_FORCE_COLOR")
|
expect(cmd_opts[:env]).to_not include("ANSIBLE_FORCE_COLOR")
|
||||||
expect(cmd_opts[:env]['ANSIBLE_NOCOLOR']).to eql("true")
|
expect(cmd_opts[:env]['ANSIBLE_NOCOLOR']).to eql("true")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -809,15 +809,21 @@ VF
|
||||||
it "raises an error when ansible-galaxy command fails", skip_before: true, skip_after: true do
|
it "raises an error when ansible-galaxy command fails", skip_before: true, skip_after: true do
|
||||||
config.finalize!
|
config.finalize!
|
||||||
|
|
||||||
subject.stub(:check_path)
|
allow(subject).to receive(:check_path)
|
||||||
Vagrant::Util::Subprocess.stub(execute: Vagrant::Util::Subprocess::Result.new(1, "", ""))
|
allow(Vagrant::Util::Subprocess).to receive(:execute)
|
||||||
|
.and_return(Vagrant::Util::Subprocess::Result.new(1, "", ""))
|
||||||
|
|
||||||
expect {subject.provision}.to raise_error(VagrantPlugins::Ansible::Errors::AnsibleCommandFailed)
|
expect {subject.provision}.to raise_error(VagrantPlugins::Ansible::Errors::AnsibleCommandFailed)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "execute ansible-galaxy and ansible-playbook" do
|
it "execute ansible-galaxy, and then ansible-playbook" do
|
||||||
# TODO: to be improved, but I'm currenty facing some issues, maybe only present in RSpec 2.14...
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |cmd, *args|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).twice
|
expect(cmd).to eq("ansible-galaxy")
|
||||||
|
}.and_return(default_execute_result)
|
||||||
|
|
||||||
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |cmd, *args|
|
||||||
|
expect(cmd).to eq("ansible-playbook")
|
||||||
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with verbose option enabled" do
|
describe "with verbose option enabled" do
|
||||||
|
@ -835,11 +841,11 @@ VF
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets ANSIBLE_ROLES_PATH with corresponding absolute path" do
|
it "sets ANSIBLE_ROLES_PATH with corresponding absolute path" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]).to include("ANSIBLE_ROLES_PATH")
|
expect(cmd_opts[:env]).to include("ANSIBLE_ROLES_PATH")
|
||||||
expect(cmd_opts[:env]['ANSIBLE_ROLES_PATH']).to eql(File.join(machine.env.root_path, "my-roles"))
|
expect(cmd_opts[:env]['ANSIBLE_ROLES_PATH']).to eql(File.join(machine.env.root_path, "my-roles"))
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -906,17 +912,17 @@ VF
|
||||||
})
|
})
|
||||||
|
|
||||||
it "also includes given raw arguments" do
|
it "also includes given raw arguments" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args).to include("--why-not")
|
expect(args).to include("--why-not")
|
||||||
expect(args).to include("--su-user=foot")
|
expect(args).to include("--su-user=foot")
|
||||||
expect(args).to include("--ask-su-pass")
|
expect(args).to include("--ask-su-pass")
|
||||||
expect(args).to include("--limit=all")
|
expect(args).to include("--limit=all")
|
||||||
expect(args).to include("--private-key=./myself.key")
|
expect(args).to include("--private-key=./myself.key")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shows the ansible-playbook command, with additional quotes when required" do
|
it "shows the ansible-playbook command, with additional quotes when required" do
|
||||||
expect(machine.env.ui).to receive(:detail).with { |full_command|
|
expect(machine.env.ui).to receive(:detail).with(any_args) { |full_command|
|
||||||
expect(full_command).to eq(%Q(PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_ROLES_PATH='/up/to the stars' ANSIBLE_CONFIG='#{existing_file}' ANSIBLE_HOST_KEY_CHECKING=true ANSIBLE_SSH_ARGS='-o IdentitiesOnly=yes -o IdentityFile=/my/key1 -o IdentityFile=/my/key2 -o ForwardAgent=yes -o ControlMaster=no -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --ask-sudo-pass --ask-vault-pass --limit="machine*:&vagrant:!that_one" --inventory-file=#{generated_inventory_dir} --extra-vars="{\\"var1\\":\\"string with 'apostrophes', \\\\\\\\, \\\\\\" and =\\",\\"var2\\":{\\"x\\":42}}" --sudo --sudo-user=deployer -vvv --vault-password-file=#{existing_file} --tags=db,www --skip-tags=foo,bar --start-at-task="joe's awesome task" --why-not --su-user=foot --ask-su-pass --limit=all --private-key=./myself.key --extra-vars='{\"var3\":\"foo\"}' playbook.yml))
|
expect(full_command).to eq(%Q(PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_ROLES_PATH='/up/to the stars' ANSIBLE_CONFIG='#{existing_file}' ANSIBLE_HOST_KEY_CHECKING=true ANSIBLE_SSH_ARGS='-o IdentitiesOnly=yes -o IdentityFile=/my/key1 -o IdentityFile=/my/key2 -o ForwardAgent=yes -o ControlMaster=no -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --ask-sudo-pass --ask-vault-pass --limit="machine*:&vagrant:!that_one" --inventory-file=#{generated_inventory_dir} --extra-vars="{\\"var1\\":\\"string with 'apostrophes', \\\\\\\\, \\\\\\" and =\\",\\"var2\\":{\\"x\\":42}}" --sudo --sudo-user=deployer -vvv --vault-password-file=#{existing_file} --tags=db,www --skip-tags=foo,bar --start-at-task="joe's awesome task" --why-not --su-user=foot --ask-su-pass --limit=all --private-key=./myself.key --extra-vars='{\"var3\":\"foo\"}' playbook.yml))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -936,21 +942,21 @@ VF
|
||||||
}}
|
}}
|
||||||
let(:fake_host_vm) {
|
let(:fake_host_vm) {
|
||||||
double("host_vm").tap do |h|
|
double("host_vm").tap do |h|
|
||||||
h.stub(ssh_info: fake_host_ssh_info)
|
allow(h).to receive(:ssh_info).and_return(fake_host_ssh_info)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(provider_name: :docker)
|
allow(machine).to receive(:provider_name).and_return(:docker)
|
||||||
machine.provider.stub(host_vm?: true)
|
allow(machine.provider).to receive(:host_vm?).and_return(true)
|
||||||
machine.provider.stub(host_vm: fake_host_vm)
|
allow(machine.provider).to receive(:host_vm).and_return(fake_host_vm)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses an SSH ProxyCommand to reach the VM" do
|
it "uses an SSH ProxyCommand to reach the VM" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o ProxyCommand='ssh boot9docker@127.0.0.1 -p 2299 -i /path/to/docker/host/key -o Compression=yes -o ConnectTimeout=5 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no exec nc %h %p 2>/dev/null'")
|
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o ProxyCommand='ssh boot9docker@127.0.0.1 -p 2299 -i /path/to/docker/host/key -o Compression=yes -o ConnectTimeout=5 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no exec nc %h %p 2>/dev/null'")
|
||||||
}
|
}.and_return(default_execute_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -960,12 +966,12 @@ VF
|
||||||
|
|
||||||
context "on a Windows host" do
|
context "on a Windows host" do
|
||||||
before do
|
before do
|
||||||
Vagrant::Util::Platform.stub(windows?: true)
|
allow(Vagrant::Util::Platform).to receive(:windows?).and_return(true)
|
||||||
machine.ui.stub(:warn)
|
allow(machine.ui).to receive(:warn)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "warns that Windows is not officially supported for the Ansible control machine" do
|
it "warns that Windows is not officially supported for the Ansible control machine" do
|
||||||
expect(machine.env.ui).to receive(:warn).with { |warning|
|
expect(machine.env.ui).to receive(:warn).with(any_args) { |warning|
|
||||||
expect(warning).to eq(I18n.t("vagrant.provisioners.ansible.windows_not_supported_for_control_machine"))
|
expect(warning).to eq(I18n.t("vagrant.provisioners.ansible.windows_not_supported_for_control_machine"))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -973,32 +979,24 @@ VF
|
||||||
|
|
||||||
context "on a Solaris-like host" do
|
context "on a Solaris-like host" do
|
||||||
before do
|
before do
|
||||||
Vagrant::Util::Platform.stub(solaris?: true)
|
allow(Vagrant::Util::Platform).to receive(:solaris?).and_return(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not set IdentitiesOnly=yes in ANSIBLE_SSH_ARGS" do
|
it "does not set IdentitiesOnly=yes in ANSIBLE_SSH_ARGS" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to_not include("-o IdentitiesOnly=yes")
|
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to_not include("-o IdentitiesOnly=yes")
|
||||||
|
}.and_return(default_execute_result)
|
||||||
# Ending this block with a negative expectation (to_not / not_to)
|
|
||||||
# would lead to a failure of the above expectation.
|
|
||||||
true
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "and with host_key_checking option enabled" do
|
describe "and with host_key_checking option enabled" do
|
||||||
it "does not set ANSIBLE_SSH_ARGS environment variable" do
|
it "does not set ANSIBLE_SSH_ARGS environment variable" do
|
||||||
config.host_key_checking = true
|
config.host_key_checking = true
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]).to_not include('ANSIBLE_SSH_ARGS')
|
expect(cmd_opts[:env]).to_not include('ANSIBLE_SSH_ARGS')
|
||||||
|
}.and_return(Vagrant::Util::Subprocess::Result.new(0, "", ""))
|
||||||
# Ending this block with a negative expectation (to_not / not_to)
|
|
||||||
# would lead to a failure of the above expectation.
|
|
||||||
true
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1008,14 +1006,10 @@ VF
|
||||||
it 'does not set IdentitiesOnly=yes in ANSIBLE_SSH_ARGS' do
|
it 'does not set IdentitiesOnly=yes in ANSIBLE_SSH_ARGS' do
|
||||||
ssh_info[:keys_only] = false
|
ssh_info[:keys_only] = false
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
cmd_opts = args.last
|
cmd_opts = args.last
|
||||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to_not include("-o IdentitiesOnly=yes")
|
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to_not include("-o IdentitiesOnly=yes")
|
||||||
|
}.and_return(default_execute_result)
|
||||||
# Ending this block with a negative expectation (to_not / not_to)
|
|
||||||
# would lead to a failure of the above expectation.
|
|
||||||
true
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,8 +20,8 @@ describe VagrantPlugins::Chef::CommandBuilder do
|
||||||
|
|
||||||
describe ".initialize" do
|
describe ".initialize" do
|
||||||
it "raises an error when chef type is not client or solo" do
|
it "raises an error when chef type is not client or solo" do
|
||||||
expect { VagrantPlugins::Chef::CommandBuilder.new(chef_config, :client_bad) }.
|
expect { VagrantPlugins::Chef::CommandBuilder.new(:client_bad, chef_config) }.
|
||||||
to raise_error
|
to raise_error(RuntimeError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not raise an error for :client" do
|
it "does not raise an error for :client" do
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
require File.expand_path("../../../../base", __FILE__)
|
require File.expand_path("../../../../base", __FILE__)
|
||||||
|
|
||||||
require Vagrant.source_root.join("plugins/provisioners/docker/config")
|
require Vagrant.source_root.join("plugins/provisioners/docker/config")
|
||||||
|
require Vagrant.source_root.join("plugins/provisioners/docker/provisioner")
|
||||||
require Vagrant.source_root.join("plugins/kernel_v2/config/vm")
|
require Vagrant.source_root.join("plugins/kernel_v2/config/vm")
|
||||||
|
|
||||||
describe VagrantPlugins::DockerProvisioner::Config do
|
describe VagrantPlugins::DockerProvisioner::Config do
|
||||||
|
@ -142,7 +143,7 @@ describe VagrantPlugins::DockerProvisioner::Config do
|
||||||
describe "#post_install_provision" do
|
describe "#post_install_provision" do
|
||||||
it "raises an error if 'docker' provisioner was provided" do
|
it "raises an error if 'docker' provisioner was provided" do
|
||||||
expect {subject.post_install_provision("myprov", :type=>"docker", :inline=>"echo 'hello'")}
|
expect {subject.post_install_provision("myprov", :type=>"docker", :inline=>"echo 'hello'")}
|
||||||
.to raise_error()
|
.to raise_error(VagrantPlugins::DockerProvisioner::DockerError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "setups a basic provisioner" do
|
it "setups a basic provisioner" do
|
||||||
|
|
|
@ -22,21 +22,21 @@ describe VagrantPlugins::DockerProvisioner::Provisioner do
|
||||||
let(:hook) { double("hook") }
|
let(:hook) { double("hook") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(communicate: communicator)
|
allow(machine).to receive(:communicate).and_return(communicator)
|
||||||
machine.stub(guest: guest)
|
allow(machine).to receive(:guest).and_return(guest)
|
||||||
|
|
||||||
communicator.stub(execute: true)
|
allow(communicator).to receive(:execute).and_return(true)
|
||||||
communicator.stub(upload: true)
|
allow(communicator).to receive(:upload).and_return(true)
|
||||||
|
|
||||||
guest.stub(capability?: false)
|
allow(guest).to receive(:capability?).and_return(false)
|
||||||
guest.stub(capability: false)
|
allow(guest).to receive(:capability).and_return(false)
|
||||||
|
|
||||||
client.stub(start_service: true)
|
allow(client).to receive(:start_service).and_return(true)
|
||||||
client.stub(daemon_running?: true)
|
allow(client).to receive(:daemon_running?).and_return(true)
|
||||||
|
|
||||||
config.stub(images: Set.new)
|
allow(config).to receive(:images).and_return(Set.new)
|
||||||
config.stub(build_images: Set.new)
|
allow(config).to receive(:build_images).and_return(Set.new)
|
||||||
config.stub(containers: Hash.new)
|
allow(config).to receive(:containers).and_return(Hash.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#provision" do
|
describe "#provision" do
|
||||||
|
@ -47,7 +47,7 @@ describe VagrantPlugins::DockerProvisioner::Provisioner do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "invokes a post_install_provisioner if defined and docker is installed" do
|
it "invokes a post_install_provisioner if defined and docker is installed" do
|
||||||
installer.stub(ensure_installed: true)
|
allow(installer).to receive(:ensure_installed).and_return(true)
|
||||||
allow(config).to receive(:post_install_provisioner).and_return(provisioner)
|
allow(config).to receive(:post_install_provisioner).and_return(provisioner)
|
||||||
allow(machine).to receive(:env).and_return(iso_env)
|
allow(machine).to receive(:env).and_return(iso_env)
|
||||||
allow(machine.env).to receive(:hook).and_return(true)
|
allow(machine.env).to receive(:hook).and_return(true)
|
||||||
|
@ -57,7 +57,7 @@ describe VagrantPlugins::DockerProvisioner::Provisioner do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not invoke post_install_provisioner if not defined" do
|
it "does not invoke post_install_provisioner if not defined" do
|
||||||
installer.stub(ensure_installed: true)
|
allow(installer).to receive(:ensure_installed).and_return(true)
|
||||||
allow(config).to receive(:post_install_provisioner).and_return(nil)
|
allow(config).to receive(:post_install_provisioner).and_return(nil)
|
||||||
allow(machine).to receive(:env).and_return(iso_env)
|
allow(machine).to receive(:env).and_return(iso_env)
|
||||||
allow(machine.env).to receive(:hook).and_return(true)
|
allow(machine.env).to receive(:hook).and_return(true)
|
||||||
|
|
|
@ -20,19 +20,19 @@ describe VagrantPlugins::FileUpload::Provisioner do
|
||||||
let(:guest) { double("guest") }
|
let(:guest) { double("guest") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(communicate: communicator)
|
allow(machine).to receive(:communicate).and_return(communicator)
|
||||||
machine.stub(guest: guest)
|
allow(machine).to receive(:guest).and_return(guest)
|
||||||
|
|
||||||
communicator.stub(execute: true)
|
allow(communicator).to receive(:execute).and_return(true)
|
||||||
communicator.stub(upload: true)
|
allow(communicator).to receive(:upload).and_return(true)
|
||||||
|
|
||||||
guest.stub(capability?: false)
|
allow(guest).to receive(:capability?).and_return(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#provision" do
|
describe "#provision" do
|
||||||
it "creates the destination directory" do
|
it "creates the destination directory" do
|
||||||
config.stub(source: "/source")
|
allow(config).to receive(:source).and_return("/source")
|
||||||
config.stub(destination: "/foo/bar")
|
allow(config).to receive(:destination).and_return("/foo/bar")
|
||||||
|
|
||||||
expect(communicator).to receive(:execute).with("mkdir -p /foo")
|
expect(communicator).to receive(:execute).with("mkdir -p /foo")
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ describe VagrantPlugins::FileUpload::Provisioner do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uploads the file" do
|
it "uploads the file" do
|
||||||
config.stub(source: "/source")
|
allow(config).to receive(:source).and_return("/source")
|
||||||
config.stub(destination: "/foo/bar")
|
allow(config).to receive(:destination).and_return("/foo/bar")
|
||||||
|
|
||||||
expect(communicator).to receive(:upload).with("/source", "/foo/bar")
|
expect(communicator).to receive(:upload).with("/source", "/foo/bar")
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ describe VagrantPlugins::FileUpload::Provisioner do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "expands the source file path" do
|
it "expands the source file path" do
|
||||||
config.stub(source: "source")
|
allow(config).to receive(:source).and_return("source")
|
||||||
config.stub(destination: "/foo/bar")
|
allow(config).to receive(:destination).and_return("/foo/bar")
|
||||||
|
|
||||||
expect(communicator).to receive(:upload).with(
|
expect(communicator).to receive(:upload).with(
|
||||||
File.expand_path("source"), "/foo/bar")
|
File.expand_path("source"), "/foo/bar")
|
||||||
|
@ -59,8 +59,8 @@ describe VagrantPlugins::FileUpload::Provisioner do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "expands the destination file path if capable" do
|
it "expands the destination file path if capable" do
|
||||||
config.stub(source: "/source")
|
allow(config).to receive(:source).and_return("/source")
|
||||||
config.stub(destination: "$HOME/foo")
|
allow(config).to receive(:destination).and_return("$HOME/foo")
|
||||||
|
|
||||||
expect(guest).to receive(:capability?).
|
expect(guest).to receive(:capability?).
|
||||||
with(:shell_expand_guest_path).and_return(true)
|
with(:shell_expand_guest_path).and_return(true)
|
||||||
|
|
|
@ -20,13 +20,13 @@ describe VagrantPlugins::Salt::Provisioner do
|
||||||
let(:guest) { double("guest") }
|
let(:guest) { double("guest") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(communicate: communicator)
|
allow(machine).to receive(:communicate).and_return(communicator)
|
||||||
machine.stub(guest: guest)
|
allow(machine).to receive(:guest).and_return(guest)
|
||||||
|
|
||||||
communicator.stub(execute: true)
|
allow(communicator).to receive(:execute).and_return(true)
|
||||||
communicator.stub(upload: true)
|
allow(communicator).to receive(:upload).and_return(true)
|
||||||
|
|
||||||
guest.stub(capability?: false)
|
allow(guest).to receive(:capability?).and_return(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#provision" do
|
describe "#provision" do
|
||||||
|
|
|
@ -7,8 +7,8 @@ describe "Vagrant::Shell::Provisioner" do
|
||||||
let(:env){ isolated_environment }
|
let(:env){ isolated_environment }
|
||||||
let(:machine) {
|
let(:machine) {
|
||||||
double(:machine, env: env, id: "ID").tap { |machine|
|
double(:machine, env: env, id: "ID").tap { |machine|
|
||||||
machine.stub_chain(:config, :vm, :communicator).and_return(:not_winrm)
|
allow(machine).to receive_message_chain(:config, :vm, :communicator).and_return(:not_winrm)
|
||||||
machine.stub_chain(:communicate, :tap) {}
|
allow(machine).to receive_message_chain(:communicate, :tap) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ describe "Vagrant::Shell::Provisioner" do
|
||||||
|
|
||||||
let(:digest){ double("digest") }
|
let(:digest){ double("digest") }
|
||||||
before do
|
before do
|
||||||
Vagrant::Util::Downloader.any_instance.should_receive(:execute_curl).and_return(true)
|
allow_any_instance_of(Vagrant::Util::Downloader).to receive(:execute_curl).and_return(true)
|
||||||
allow(digest).to receive(:file).and_return(digest)
|
allow(digest).to receive(:file).and_return(digest)
|
||||||
expect(Digest::SHA1).to receive(:new).and_return(digest)
|
expect(Digest::SHA1).to receive(:new).and_return(digest)
|
||||||
expect(digest).to receive(:hexdigest).and_return('INVALID_VALUE')
|
expect(digest).to receive(:hexdigest).and_return('INVALID_VALUE')
|
||||||
|
@ -92,7 +92,7 @@ describe "Vagrant::Shell::Provisioner" do
|
||||||
|
|
||||||
let(:digest){ double("digest") }
|
let(:digest){ double("digest") }
|
||||||
before do
|
before do
|
||||||
Vagrant::Util::Downloader.any_instance.should_receive(:execute_curl).and_return(true)
|
allow_any_instance_of(Vagrant::Util::Downloader).to receive(:execute_curl).and_return(true)
|
||||||
allow(digest).to receive(:file).and_return(digest)
|
allow(digest).to receive(:file).and_return(digest)
|
||||||
expect(Digest::MD5).to receive(:new).and_return(digest)
|
expect(Digest::MD5).to receive(:new).and_return(digest)
|
||||||
expect(digest).to receive(:hexdigest).and_return('INVALID_VALUE')
|
expect(digest).to receive(:hexdigest).and_return('INVALID_VALUE')
|
||||||
|
|
|
@ -109,6 +109,7 @@ describe VagrantPlugins::FTPPush::SFTPAdapter do
|
||||||
describe "#upload" do
|
describe "#upload" do
|
||||||
it "uploads the file" do
|
it "uploads the file" do
|
||||||
pending "a way to mock an SFTP server"
|
pending "a way to mock an SFTP server"
|
||||||
|
test_with_mock_sftp_server
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe VagrantPlugins::SyncedFolderNFS::ActionCleanup do
|
||||||
subject { described_class.new(app, env) }
|
subject { described_class.new(app, env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.env.stub(host: host)
|
allow(machine.env).to receive(:host).and_return(host)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does nothing if there are no valid IDs" do
|
it "does nothing if there are no valid IDs" do
|
||||||
|
|
|
@ -10,7 +10,7 @@ describe VagrantPlugins::SyncedFolderNFS::Config do
|
||||||
subject.finalize!
|
subject.finalize!
|
||||||
end
|
end
|
||||||
|
|
||||||
its(:functional) { should be_true }
|
its(:functional) { should be(true) }
|
||||||
its(:map_gid) { should eq(:auto) }
|
its(:map_gid) { should eq(:auto) }
|
||||||
its(:map_uid) { should eq(:auto) }
|
its(:map_uid) { should eq(:auto) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,17 +34,17 @@ describe VagrantPlugins::SyncedFolderRSync::Command::RsyncAuto do
|
||||||
|
|
||||||
def machine_stub(name)
|
def machine_stub(name)
|
||||||
double(name).tap do |m|
|
double(name).tap do |m|
|
||||||
m.stub(id: "foo")
|
allow(m).to receive(:id).and_return("foo")
|
||||||
m.stub(reload: nil)
|
allow(m).to receive(:reload).and_return(nil)
|
||||||
m.stub(ssh_info: ssh_info)
|
allow(m).to receive(:ssh_info).and_return(ssh_info)
|
||||||
m.stub(ui: iso_env.ui)
|
allow(m).to receive(:ui).and_return(iso_env.ui)
|
||||||
m.stub(provider: double("provider"))
|
allow(m).to receive(:provider).and_return(double("provider"))
|
||||||
m.stub(state: double("state", id: :not_created))
|
allow(m).to receive(:state).and_return(double("state", id: :not_created))
|
||||||
m.stub(env: iso_env)
|
allow(m).to receive(:env).and_return(iso_env)
|
||||||
m.stub(config: double("config"))
|
allow(m).to receive(:config).and_return(double("config"))
|
||||||
|
|
||||||
|
|
||||||
m.ui.stub(error: nil)
|
allow(m.ui).to receive(:error).and_return(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ describe VagrantPlugins::SyncedFolderRSync::Command::RsyncAuto do
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
described_class.new(argv, iso_env).tap do |s|
|
described_class.new(argv, iso_env).tap do |s|
|
||||||
s.stub(synced_folders: synced_folders_empty)
|
allow(s).to receive(:synced_folders).and_return(synced_folders_empty)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ describe VagrantPlugins::SyncedFolderRSync::Command::RsyncAuto do
|
||||||
]
|
]
|
||||||
|
|
||||||
paths["/foo"].each do |data|
|
paths["/foo"].each do |data|
|
||||||
data[:machine].stub(id: nil)
|
allow(data[:machine]).to receive(:id).and_return(nil)
|
||||||
expect(helper_class).to_not receive(:rsync_single)
|
expect(helper_class).to_not receive(:rsync_single)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,14 @@ describe VagrantPlugins::SyncedFolderRSync::Command::Rsync do
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
described_class.new(argv, iso_env).tap do |s|
|
described_class.new(argv, iso_env).tap do |s|
|
||||||
s.stub(synced_folders: synced_folders)
|
allow(s).to receive(:synced_folders).and_return(synced_folders)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
iso_env.machine_names.each do |name|
|
iso_env.machine_names.each do |name|
|
||||||
m = iso_env.machine(name, iso_env.default_provider)
|
m = iso_env.machine(name, iso_env.default_provider)
|
||||||
m.stub(communicate: communicator)
|
allow(m).to receive(:communicate).and_return(communicator)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ describe VagrantPlugins::SyncedFolderRSync::Command::Rsync do
|
||||||
let(:machine) { iso_env.machine(iso_env.machine_names[0], iso_env.default_provider) }
|
let(:machine) { iso_env.machine(iso_env.machine_names[0], iso_env.default_provider) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
communicator.stub(ready?: true)
|
allow(communicator).to receive(:ready?).and_return(true)
|
||||||
machine.stub(ssh_info: ssh_info)
|
allow(machine).to receive(:ssh_info).and_return(ssh_info)
|
||||||
|
|
||||||
synced_folders[:rsync] = [
|
synced_folders[:rsync] = [
|
||||||
[:one, {}],
|
[:one, {}],
|
||||||
|
@ -51,7 +51,7 @@ describe VagrantPlugins::SyncedFolderRSync::Command::Rsync do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't sync if communicator isn't ready and exits with 1" do
|
it "doesn't sync if communicator isn't ready and exits with 1" do
|
||||||
communicator.stub(ready?: false)
|
allow(communicator).to receive(:ready?).and_return(false)
|
||||||
|
|
||||||
expect(helper_class).to receive(:rsync_single).never
|
expect(helper_class).to receive(:rsync_single).never
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
subject { described_class }
|
subject { described_class }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(guest: guest)
|
allow(machine).to receive(:guest).and_return(guest)
|
||||||
|
|
||||||
# Don't do all the crazy Cygwin stuff
|
# Don't do all the crazy Cygwin stuff
|
||||||
allow(Vagrant::Util::Platform).to receive(:cygwin_path) do |path, **opts|
|
allow(Vagrant::Util::Platform).to receive(:cygwin_path) do |path, **opts|
|
||||||
|
@ -64,9 +64,9 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
let(:ui) { machine.ui }
|
let(:ui) { machine.ui }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant::Util::Subprocess.stub(execute: result)
|
allow(Vagrant::Util::Subprocess).to receive(:execute){ result }
|
||||||
|
|
||||||
guest.stub(capability?: false)
|
allow(guest).to receive(:capability?){ false }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't raise an error if it succeeds" do
|
it "doesn't raise an error if it succeeds" do
|
||||||
|
@ -74,25 +74,25 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't call cygwin_path on non-Windows" do
|
it "doesn't call cygwin_path on non-Windows" do
|
||||||
Vagrant::Util::Platform.stub(windows?: false)
|
allow(Vagrant::Util::Platform).to receive(:windows?).and_return(false)
|
||||||
expect(Vagrant::Util::Platform).not_to receive(:cygwin_path)
|
expect(Vagrant::Util::Platform).not_to receive(:cygwin_path)
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calls cygwin_path on Windows" do
|
it "calls cygwin_path on Windows" do
|
||||||
Vagrant::Util::Platform.stub(windows?: true)
|
allow(Vagrant::Util::Platform).to receive(:windows?).and_return(true)
|
||||||
expect(Vagrant::Util::Platform).to receive(:cygwin_path).and_return("foo")
|
expect(Vagrant::Util::Platform).to receive(:cygwin_path).and_return("foo")
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args[args.length - 3]).to eql("foo/")
|
expect(args[args.length - 3]).to eql("foo/")
|
||||||
}
|
}.and_return(result)
|
||||||
|
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if the exit code is non-zero" do
|
it "raises an error if the exit code is non-zero" do
|
||||||
Vagrant::Util::Subprocess.stub(
|
allow(Vagrant::Util::Subprocess).to receive(:execute)
|
||||||
execute: Vagrant::Util::Subprocess::Result.new(1, "", ""))
|
.and_return(Vagrant::Util::Subprocess::Result.new(1, "", ""))
|
||||||
|
|
||||||
expect {subject.rsync_single(machine, ssh_info, opts) }.
|
expect {subject.rsync_single(machine, ssh_info, opts) }.
|
||||||
to raise_error(Vagrant::Errors::RSyncError)
|
to raise_error(Vagrant::Errors::RSyncError)
|
||||||
|
@ -103,11 +103,11 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
opts[:hostpath] = "/foo"
|
opts[:hostpath] = "/foo"
|
||||||
opts[:guestpath] = "/bar"
|
opts[:guestpath] = "/bar"
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expected = Vagrant::Util::Platform.fs_real_path("/foo").to_s
|
expected = Vagrant::Util::Platform.fs_real_path("/foo").to_s
|
||||||
expect(args[args.length - 3]).to eql("#{expected}/")
|
expect(args[args.length - 3]).to eql("#{expected}/")
|
||||||
expect(args[args.length - 2]).to include("/bar")
|
expect(args[args.length - 2]).to include("/bar")
|
||||||
}
|
}.and_return(result)
|
||||||
|
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
|
@ -118,22 +118,22 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
|
|
||||||
hostpath_expanded = File.expand_path(opts[:hostpath], machine.env.root_path)
|
hostpath_expanded = File.expand_path(opts[:hostpath], machine.env.root_path)
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args[args.length - 3]).to eql("#{hostpath_expanded}/")
|
expect(args[args.length - 3]).to eql("#{hostpath_expanded}/")
|
||||||
expect(args[args.length - 2]).to include("/bar")
|
expect(args[args.length - 2]).to include("/bar")
|
||||||
}
|
}.and_return(result)
|
||||||
|
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "executes within the root path" do
|
it "executes within the root path" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args.last).to be_kind_of(Hash)
|
expect(args.last).to be_kind_of(Hash)
|
||||||
|
|
||||||
opts = args.last
|
opts = args.last
|
||||||
expect(opts[:workdir]).to eql(machine.env.root_path.to_s)
|
expect(opts[:workdir]).to eql(machine.env.root_path.to_s)
|
||||||
}
|
}.and_return(result)
|
||||||
|
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
|
@ -158,11 +158,11 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
it "excludes files if given as a string" do
|
it "excludes files if given as a string" do
|
||||||
opts[:exclude] = "foo"
|
opts[:exclude] = "foo"
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
index = args.find_index("foo")
|
index = args.find_index("foo")
|
||||||
expect(index).to be > 0
|
expect(index).to be > 0
|
||||||
expect(args[index-1]).to eql("--exclude")
|
expect(args[index-1]).to eql("--exclude")
|
||||||
}
|
}.and_return(result)
|
||||||
|
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
|
@ -170,7 +170,7 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
it "excludes multiple files" do
|
it "excludes multiple files" do
|
||||||
opts[:exclude] = ["foo", "bar"]
|
opts[:exclude] = ["foo", "bar"]
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
index = args.find_index("foo")
|
index = args.find_index("foo")
|
||||||
expect(index).to be > 0
|
expect(index).to be > 0
|
||||||
expect(args[index-1]).to eql("--exclude")
|
expect(args[index-1]).to eql("--exclude")
|
||||||
|
@ -178,7 +178,7 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
index = args.find_index("bar")
|
index = args.find_index("bar")
|
||||||
expect(index).to be > 0
|
expect(index).to be > 0
|
||||||
expect(args[index-1]).to eql("--exclude")
|
expect(args[index-1]).to eql("--exclude")
|
||||||
}
|
}.and_return(result)
|
||||||
|
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
|
@ -186,14 +186,14 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
|
|
||||||
context "custom arguments" do
|
context "custom arguments" do
|
||||||
it "uses the default arguments if not given" do
|
it "uses the default arguments if not given" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args[1]).to eq("--verbose")
|
expect(args[1]).to eq("--verbose")
|
||||||
expect(args[2]).to eq("--archive")
|
expect(args[2]).to eq("--archive")
|
||||||
expect(args[3]).to eq("--delete")
|
expect(args[3]).to eq("--delete")
|
||||||
|
|
||||||
expected = Vagrant::Util::Platform.fs_real_path("/foo").to_s
|
expected = Vagrant::Util::Platform.fs_real_path("/foo").to_s
|
||||||
expect(args[args.length - 3]).to eql("#{expected}/")
|
expect(args[args.length - 3]).to eql("#{expected}/")
|
||||||
}
|
}.and_return(result)
|
||||||
|
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
|
@ -201,13 +201,13 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
it "uses the custom arguments if given" do
|
it "uses the custom arguments if given" do
|
||||||
opts[:args] = ["--verbose", "-z"]
|
opts[:args] = ["--verbose", "-z"]
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args[1]).to eq("--verbose")
|
expect(args[1]).to eq("--verbose")
|
||||||
expect(args[2]).to eq("-z")
|
expect(args[2]).to eq("-z")
|
||||||
|
|
||||||
expected = Vagrant::Util::Platform.fs_real_path("/foo").to_s
|
expected = Vagrant::Util::Platform.fs_real_path("/foo").to_s
|
||||||
expect(args[args.length - 3]).to eql("#{expected}/")
|
expect(args[args.length - 3]).to eql("#{expected}/")
|
||||||
}
|
}.and_return(result)
|
||||||
|
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
|
@ -228,19 +228,19 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
let(:ui) { machine.ui }
|
let(:ui) { machine.ui }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant::Util::Subprocess.stub(execute: result)
|
allow(Vagrant::Util::Subprocess).to receive(:execute){ result }
|
||||||
|
|
||||||
guest.stub(capability?: false)
|
allow(guest).to receive(:capability?){ false }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "includes IdentitiesOnly, StrictHostKeyChecking, and UserKnownHostsFile with defaults" do
|
it "includes IdentitiesOnly, StrictHostKeyChecking, and UserKnownHostsFile with defaults" do
|
||||||
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|
|
||||||
expect(args[9]).to include('IdentitiesOnly')
|
expect(args[9]).to include('IdentitiesOnly')
|
||||||
expect(args[9]).to include('StrictHostKeyChecking')
|
expect(args[9]).to include('StrictHostKeyChecking')
|
||||||
expect(args[9]).to include('UserKnownHostsFile')
|
expect(args[9]).to include('UserKnownHostsFile')
|
||||||
expect(args[9]).to include("-i '/path/to/key'")
|
expect(args[9]).to include("-i '/path/to/key'")
|
||||||
}
|
}.and_return(result)
|
||||||
|
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
|
@ -248,7 +248,7 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
it "omits IdentitiesOnly with keys_only = false" do
|
it "omits IdentitiesOnly with keys_only = false" do
|
||||||
ssh_info[:keys_only] = false
|
ssh_info[:keys_only] = false
|
||||||
|
|
||||||
Vagrant::Util::Subprocess.should_receive(:execute) do |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args|
|
||||||
expect(args[9]).not_to include('IdentitiesOnly')
|
expect(args[9]).not_to include('IdentitiesOnly')
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
@ -259,7 +259,7 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
it "omits StrictHostKeyChecking and UserKnownHostsFile with paranoid = true" do
|
it "omits StrictHostKeyChecking and UserKnownHostsFile with paranoid = true" do
|
||||||
ssh_info[:keys_only] = false
|
ssh_info[:keys_only] = false
|
||||||
|
|
||||||
Vagrant::Util::Subprocess.should_receive(:execute) do |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args|
|
||||||
expect(args[9]).not_to include('StrictHostKeyChecking ')
|
expect(args[9]).not_to include('StrictHostKeyChecking ')
|
||||||
expect(args[9]).not_to include('UserKnownHostsFile ')
|
expect(args[9]).not_to include('UserKnownHostsFile ')
|
||||||
result
|
result
|
||||||
|
|
|
@ -19,19 +19,19 @@ describe VagrantPlugins::SyncedFolderRSync::SyncedFolder do
|
||||||
let(:helper_class) { VagrantPlugins::SyncedFolderRSync::RsyncHelper }
|
let(:helper_class) { VagrantPlugins::SyncedFolderRSync::RsyncHelper }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.env.stub(host: host)
|
allow(machine.env).to receive(:host).and_return(host)
|
||||||
machine.stub(guest: guest)
|
allow(machine).to receive(:guest).and_return(guest)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#usable?" do
|
describe "#usable?" do
|
||||||
it "is usable if rsync can be found" do
|
it "is usable if rsync can be found" do
|
||||||
expect(Vagrant::Util::Which).to receive(:which).with("rsync").and_return(true)
|
expect(Vagrant::Util::Which).to receive(:which).with("rsync").and_return(true)
|
||||||
expect(subject.usable?(machine)).to be_true
|
expect(subject.usable?(machine)).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is not usable if rsync cant be found" do
|
it "is not usable if rsync cant be found" do
|
||||||
expect(Vagrant::Util::Which).to receive(:which).with("rsync").and_return(false)
|
expect(Vagrant::Util::Which).to receive(:which).with("rsync").and_return(false)
|
||||||
expect(subject.usable?(machine)).to be_false
|
expect(subject.usable?(machine)).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an exception if asked to" do
|
it "raises an exception if asked to" do
|
||||||
|
@ -47,7 +47,7 @@ describe VagrantPlugins::SyncedFolderRSync::SyncedFolder do
|
||||||
}}
|
}}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(ssh_info: ssh_info)
|
allow(machine).to receive(:ssh_info).and_return(ssh_info)
|
||||||
allow(guest).to receive(:capability?).with(:rsync_installed)
|
allow(guest).to receive(:capability?).with(:rsync_installed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
box_collection.stub(find: nil)
|
allow(box_collection).to receive(:find).and_return(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with box file directly" do
|
context "with box file directly" do
|
||||||
|
@ -91,7 +91,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
env[:box_name] = "foo"
|
env[:box_name] = "foo"
|
||||||
env[:box_url] = box_path.to_s
|
env[:box_url] = box_path.to_s
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo")
|
expect(name).to eq("foo")
|
||||||
expect(version).to eq("0")
|
expect(version).to eq("0")
|
||||||
|
@ -113,7 +113,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
box_path.to_s,
|
box_path.to_s,
|
||||||
]
|
]
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo")
|
expect(name).to eq("foo")
|
||||||
expect(version).to eq("0")
|
expect(version).to eq("0")
|
||||||
|
@ -132,7 +132,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
env[:box_name] = "foo"
|
env[:box_name] = "foo"
|
||||||
env[:box_url] = "http://127.0.0.1:#{port}/#{box_path.basename}"
|
env[:box_url] = "http://127.0.0.1:#{port}/#{box_path.basename}"
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo")
|
expect(name).to eq("foo")
|
||||||
expect(version).to eq("0")
|
expect(version).to eq("0")
|
||||||
|
@ -152,7 +152,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
env[:box_name] = "foo"
|
env[:box_name] = "foo"
|
||||||
env[:box_url] = "ftp://127.0.0.1:#{port}/#{box_path.basename}"
|
env[:box_url] = "ftp://127.0.0.1:#{port}/#{box_path.basename}"
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo")
|
expect(name).to eq("foo")
|
||||||
expect(version).to eq("0")
|
expect(version).to eq("0")
|
||||||
|
@ -267,8 +267,8 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
env[:box_url] = box_path.to_s
|
env[:box_url] = box_path.to_s
|
||||||
env[:box_provider] = "virtualbox"
|
env[:box_provider] = "virtualbox"
|
||||||
|
|
||||||
box_collection.stub(find: box)
|
allow(box_collection).to receive(:find).and_return(box)
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo")
|
expect(name).to eq("foo")
|
||||||
expect(version).to eq("0")
|
expect(version).to eq("0")
|
||||||
|
@ -288,7 +288,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
box_url_name = "http://127.0.0.1:#{port}/#{box_path.basename}"
|
box_url_name = "http://127.0.0.1:#{port}/#{box_path.basename}"
|
||||||
env[:box_name] = box_url_name
|
env[:box_name] = box_url_name
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(name).to eq(box_url_name)
|
expect(name).to eq(box_url_name)
|
||||||
expect(version).to eq("0")
|
expect(version).to eq("0")
|
||||||
expect(opts[:metadata_url]).to be_nil
|
expect(opts[:metadata_url]).to be_nil
|
||||||
|
@ -313,7 +313,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
box_url_name = "box name with spaces"
|
box_url_name = "box name with spaces"
|
||||||
env[:box_name] = box_url_name
|
env[:box_name] = box_url_name
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(name).to eq(box_url_name)
|
expect(name).to eq(box_url_name)
|
||||||
expect(version).to eq("0")
|
expect(version).to eq("0")
|
||||||
expect(opts[:metadata_url]).to be_nil
|
expect(opts[:metadata_url]).to be_nil
|
||||||
|
@ -337,7 +337,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
env[:box_name] = "foo"
|
env[:box_name] = "foo"
|
||||||
env[:box_url] = "http://#{username}:#{password}@127.0.0.1:#{port}/#{box_path.basename}"
|
env[:box_url] = "http://#{username}:#{password}@127.0.0.1:#{port}/#{box_path.basename}"
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo")
|
expect(name).to eq("foo")
|
||||||
expect(version).to eq("0")
|
expect(version).to eq("0")
|
||||||
|
@ -385,7 +385,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
with_web_server(md_path) do |port|
|
with_web_server(md_path) do |port|
|
||||||
env[:box_url] = "http://127.0.0.1:#{port}/#{md_path.basename}"
|
env[:box_url] = "http://127.0.0.1:#{port}/#{md_path.basename}"
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
|
@ -430,7 +430,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
with_web_server(md_path, **opts) do |port|
|
with_web_server(md_path, **opts) do |port|
|
||||||
env[:box_url] = "http://127.0.0.1:#{port}/#{md_path.basename}"
|
env[:box_url] = "http://127.0.0.1:#{port}/#{md_path.basename}"
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
|
@ -475,7 +475,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
url = "http://127.0.0.1:#{port}"
|
url = "http://127.0.0.1:#{port}"
|
||||||
env[:box_url] = "mitchellh/precise64.json"
|
env[:box_url] = "mitchellh/precise64.json"
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(name).to eq("mitchellh/precise64")
|
expect(name).to eq("mitchellh/precise64")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
|
@ -526,7 +526,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
env[:box_url] = "mitchellh/precise64.json"
|
env[:box_url] = "mitchellh/precise64.json"
|
||||||
env[:box_server_url] = url
|
env[:box_server_url] = url
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(name).to eq("mitchellh/precise64")
|
expect(name).to eq("mitchellh/precise64")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
|
@ -587,7 +587,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
|
@ -632,7 +632,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
with_web_server(md_path) do |port|
|
with_web_server(md_path) do |port|
|
||||||
env[:box_url] = "http://127.0.0.1:#{port}/#{md_path.basename}"
|
env[:box_url] = "http://127.0.0.1:#{port}/#{md_path.basename}"
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
|
@ -691,7 +691,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
expect(box_collection).to receive(:add).never
|
expect(box_collection).to receive(:add).never
|
||||||
expect(app).to receive(:call).never
|
expect(app).to receive(:call).never
|
||||||
|
|
||||||
Vagrant.stub(server_url: nil)
|
allow(Vagrant).to receive(:server_url).and_return(nil)
|
||||||
|
|
||||||
expect { subject.call(env) }.
|
expect { subject.call(env) }.
|
||||||
to raise_error(Vagrant::Errors::BoxServerNotSet)
|
to raise_error(Vagrant::Errors::BoxServerNotSet)
|
||||||
|
@ -776,7 +776,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
end
|
end
|
||||||
|
|
||||||
env[:box_url] = tf.path
|
env[:box_url] = tf.path
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
|
@ -820,7 +820,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
|
|
||||||
env[:box_url] = tf.path
|
env[:box_url] = tf.path
|
||||||
env[:box_provider] = "vmware"
|
env[:box_provider] = "vmware"
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
|
@ -869,7 +869,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
|
|
||||||
env[:box_url] = tf.path
|
env[:box_url] = tf.path
|
||||||
env[:box_provider] = "vmware"
|
env[:box_provider] = "vmware"
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
|
@ -909,7 +909,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
|
|
||||||
env[:box_url] = tf.path
|
env[:box_url] = tf.path
|
||||||
env[:box_version] = "~> 0.1"
|
env[:box_version] = "~> 0.1"
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.5")
|
expect(version).to eq("0.5")
|
||||||
|
@ -954,7 +954,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
env[:box_url] = tf.path
|
env[:box_url] = tf.path
|
||||||
env[:box_provider] = "vmware"
|
env[:box_provider] = "vmware"
|
||||||
env[:box_version] = "~> 0.1"
|
env[:box_version] = "~> 0.1"
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.5")
|
expect(version).to eq("0.5")
|
||||||
|
@ -1002,7 +1002,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
|
|
||||||
env[:box_url] = tf.path
|
env[:box_url] = tf.path
|
||||||
env[:box_provider] = ["virtualbox", "vmware"]
|
env[:box_provider] = ["virtualbox", "vmware"]
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
|
@ -1050,7 +1050,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
|
|
||||||
expect(env[:ui]).to receive(:ask).and_return("1")
|
expect(env[:ui]).to receive(:ask).and_return("1")
|
||||||
|
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
|
@ -1225,12 +1225,12 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
|
||||||
|
|
||||||
env[:box_force] = true
|
env[:box_force] = true
|
||||||
env[:box_url] = tf.path
|
env[:box_url] = tf.path
|
||||||
box_collection.stub(find: box)
|
allow(box_collection).to receive(:find).and_return(box)
|
||||||
expect(box_collection).to receive(:add).with { |path, name, version, **opts|
|
expect(box_collection).to receive(:add).with(any_args) { |path, name, version, **opts|
|
||||||
expect(checksum(path)).to eq(checksum(box_path))
|
expect(checksum(path)).to eq(checksum(box_path))
|
||||||
expect(name).to eq("foo/bar")
|
expect(name).to eq("foo/bar")
|
||||||
expect(version).to eq("0.7")
|
expect(version).to eq("0.7")
|
||||||
expect(opts[:force]).to be_true
|
expect(opts[:force]).to be(true)
|
||||||
expect(opts[:metadata_url]).to eq("file://#{tf.path}")
|
expect(opts[:metadata_url]).to eq("file://#{tf.path}")
|
||||||
true
|
true
|
||||||
}.and_return(box)
|
}.and_return(box)
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
|
||||||
let(:box) do
|
let(:box) do
|
||||||
box_dir = iso_env.box3("foo", "1.0", :virtualbox)
|
box_dir = iso_env.box3("foo", "1.0", :virtualbox)
|
||||||
Vagrant::Box.new("foo", :virtualbox, "1.0", box_dir).tap do |b|
|
Vagrant::Box.new("foo", :virtualbox, "1.0", box_dir).tap do |b|
|
||||||
b.stub(has_update?: nil)
|
allow(b).to receive(:has_update?).and_return(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(box: box)
|
allow(machine).to receive(:box).and_return(box)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "disabling outdated checking" do
|
context "disabling outdated checking" do
|
||||||
|
@ -63,7 +63,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
|
||||||
|
|
||||||
context "no box" do
|
context "no box" do
|
||||||
it "raises an exception if the machine doesn't have a box yet" do
|
it "raises an exception if the machine doesn't have a box yet" do
|
||||||
machine.stub(box: nil)
|
allow(machine).to receive(:box).and_return(nil)
|
||||||
|
|
||||||
expect(app).to receive(:call).with(env).once
|
expect(app).to receive(:call).with(env).once
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
|
||||||
|
|
||||||
context "with a non-versioned box" do
|
context "with a non-versioned box" do
|
||||||
it "does nothing" do
|
it "does nothing" do
|
||||||
box.stub(metadata_url: nil)
|
allow(box).to receive(:metadata_url).and_return(nil)
|
||||||
box.stub(version: "0")
|
allow(box).to receive(:version).and_return("0")
|
||||||
|
|
||||||
expect(app).to receive(:call).once
|
expect(app).to receive(:call).once
|
||||||
expect(box).to receive(:has_update?).never
|
expect(box).to receive(:has_update?).never
|
||||||
|
@ -93,7 +93,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
|
|
||||||
expect(env[:box_outdated]).to be_false
|
expect(env[:box_outdated]).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets env if there is an update" do
|
it "sets env if there is an update" do
|
||||||
|
@ -126,7 +126,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
|
|
||||||
expect(env[:box_outdated]).to be_true
|
expect(env[:box_outdated]).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has an update if it is local" do
|
it "has an update if it is local" do
|
||||||
|
@ -138,7 +138,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
|
|
||||||
expect(env[:box_outdated]).to be_true
|
expect(env[:box_outdated]).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not have a local update if not within constraints" do
|
it "does not have a local update if not within constraints" do
|
||||||
|
@ -152,7 +152,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
|
|
||||||
expect(env[:box_outdated]).to be_false
|
expect(env[:box_outdated]).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does nothing if metadata download fails" do
|
it "does nothing if metadata download fails" do
|
||||||
|
@ -163,7 +163,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
|
|
||||||
expect(env[:box_outdated]).to be_false
|
expect(env[:box_outdated]).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises error if has_update? errors" do
|
it "raises error if has_update? errors" do
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "deletes the box if it is the only option" do
|
it "deletes the box if it is the only option" do
|
||||||
box_collection.stub(all: [["foo", "1.0", :virtualbox]])
|
allow(box_collection).to receive(:all).and_return([["foo", "1.0", :virtualbox]])
|
||||||
|
|
||||||
env[:box_name] = "foo"
|
env[:box_name] = "foo"
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "deletes the box with the specified provider if given" do
|
it "deletes the box with the specified provider if given" do
|
||||||
box_collection.stub(
|
allow(box_collection).to receive(:all)
|
||||||
all: [
|
.and_return([
|
||||||
["foo", "1.0", :virtualbox],
|
["foo", "1.0", :virtualbox],
|
||||||
["foo", "1.0", :vmware],
|
["foo", "1.0", :vmware],
|
||||||
])
|
])
|
||||||
|
@ -63,8 +63,8 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "deletes the box with the specified version if given" do
|
it "deletes the box with the specified version if given" do
|
||||||
box_collection.stub(
|
allow(box_collection).to receive(:all)
|
||||||
all: [
|
.and_return([
|
||||||
["foo", "1.0", :virtualbox],
|
["foo", "1.0", :virtualbox],
|
||||||
["foo", "1.1", :virtualbox],
|
["foo", "1.1", :virtualbox],
|
||||||
])
|
])
|
||||||
|
@ -93,7 +93,7 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
||||||
"version" => "1.0",
|
"version" => "1.0",
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.stub(valid?: valid)
|
allow(entry).to receive(:valid?).and_return(valid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -102,8 +102,8 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
||||||
before do
|
before do
|
||||||
env[:action_runner] = action_runner
|
env[:action_runner] = action_runner
|
||||||
|
|
||||||
box_collection.stub(
|
allow(box_collection).to receive(:all)
|
||||||
all: [
|
.and_return([
|
||||||
["foo", "1.0", :virtualbox],
|
["foo", "1.0", :virtualbox],
|
||||||
["foo", "1.1", :virtualbox],
|
["foo", "1.1", :virtualbox],
|
||||||
])
|
])
|
||||||
|
@ -154,7 +154,7 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "errors if the box doesn't exist" do
|
it "errors if the box doesn't exist" do
|
||||||
box_collection.stub(all: [])
|
allow(box_collection).to receive(:all).and_return([])
|
||||||
|
|
||||||
expect(app).to receive(:call).never
|
expect(app).to receive(:call).never
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
||||||
env[:box_name] = "foo"
|
env[:box_name] = "foo"
|
||||||
env[:box_provider] = "bar"
|
env[:box_provider] = "bar"
|
||||||
|
|
||||||
box_collection.stub(all: [["foo", "1.0", :virtualbox]])
|
allow(box_collection).to receive(:all).and_return([["foo", "1.0", :virtualbox]])
|
||||||
|
|
||||||
expect(app).to receive(:call).never
|
expect(app).to receive(:call).never
|
||||||
|
|
||||||
|
@ -177,8 +177,8 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
||||||
it "errors if there are multiple providers" do
|
it "errors if there are multiple providers" do
|
||||||
env[:box_name] = "foo"
|
env[:box_name] = "foo"
|
||||||
|
|
||||||
box_collection.stub(
|
allow(box_collection).to receive(:all)
|
||||||
all: [
|
.and_return([
|
||||||
["foo", "1.0", :virtualbox],
|
["foo", "1.0", :virtualbox],
|
||||||
["foo", "1.0", :vmware],
|
["foo", "1.0", :vmware],
|
||||||
])
|
])
|
||||||
|
@ -193,8 +193,8 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
||||||
env[:box_name] = "foo"
|
env[:box_name] = "foo"
|
||||||
env[:box_provider] = "virtualbox"
|
env[:box_provider] = "virtualbox"
|
||||||
|
|
||||||
box_collection.stub(
|
allow(box_collection).to receive(:all)
|
||||||
all: [
|
.and_return([
|
||||||
["foo", "1.0", :virtualbox],
|
["foo", "1.0", :virtualbox],
|
||||||
["foo", "1.1", :virtualbox],
|
["foo", "1.1", :virtualbox],
|
||||||
])
|
])
|
||||||
|
@ -209,7 +209,7 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
||||||
env[:box_name] = "foo"
|
env[:box_name] = "foo"
|
||||||
env[:box_version] = "1.1"
|
env[:box_version] = "1.1"
|
||||||
|
|
||||||
box_collection.stub(all: [["foo", "1.0", :virtualbox]])
|
allow(box_collection).to receive(:all).and_return([["foo", "1.0", :virtualbox]])
|
||||||
|
|
||||||
expect(app).to receive(:call).never
|
expect(app).to receive(:call).never
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ describe Vagrant::Action::Builtin::Confirm do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
described_class.new(app, env, message, allowed: ["y", "N"]).call(env)
|
described_class.new(app, env, message, allowed: ["y", "N"]).call(env)
|
||||||
expect(env[:result]).to be_true
|
expect(env[:result]).to be(true)
|
||||||
expect(times).to eq(4)
|
expect(times).to eq(4)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,8 +13,8 @@ describe Vagrant::Action::Builtin::GracefulHalt do
|
||||||
let(:machine_config) do
|
let(:machine_config) do
|
||||||
double("machine_config").tap do |top_config|
|
double("machine_config").tap do |top_config|
|
||||||
vm_config = double("machien_vm_config")
|
vm_config = double("machien_vm_config")
|
||||||
vm_config.stub(graceful_halt_timeout: 10)
|
allow(vm_config).to receive(:graceful_halt_timeout).and_return(10)
|
||||||
top_config.stub(vm: vm_config)
|
allow(top_config).to receive(:vm).and_return(vm_config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
let(:machine_guest) { double("machine_guest") }
|
let(:machine_guest) { double("machine_guest") }
|
||||||
|
|
|
@ -38,7 +38,7 @@ describe Vagrant::Action::Builtin::HandleBox do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't do anything if a box exists" do
|
it "doesn't do anything if a box exists" do
|
||||||
machine.stub(box: box)
|
allow(machine).to receive(:box).and_return(box)
|
||||||
|
|
||||||
expect(action_runner).to receive(:run).never
|
expect(action_runner).to receive(:run).never
|
||||||
expect(app).to receive(:call).with(env)
|
expect(app).to receive(:call).with(env)
|
||||||
|
@ -48,13 +48,13 @@ describe Vagrant::Action::Builtin::HandleBox do
|
||||||
|
|
||||||
context "with a box set and no box_url" do
|
context "with a box set and no box_url" do
|
||||||
before do
|
before do
|
||||||
machine.stub(box: nil)
|
allow(machine).to receive(:box).and_return(nil)
|
||||||
|
|
||||||
machine.config.vm.box = "foo"
|
machine.config.vm.box = "foo"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds a box that doesn't exist" do
|
it "adds a box that doesn't exist" do
|
||||||
expect(action_runner).to receive(:run).with { |action, opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, opts|
|
||||||
expect(opts[:box_name]).to eq(machine.config.vm.box)
|
expect(opts[:box_name]).to eq(machine.config.vm.box)
|
||||||
expect(opts[:box_url]).to eq(machine.config.vm.box)
|
expect(opts[:box_url]).to eq(machine.config.vm.box)
|
||||||
expect(opts[:box_provider]).to eq(:dummy)
|
expect(opts[:box_provider]).to eq(:dummy)
|
||||||
|
@ -70,7 +70,7 @@ describe Vagrant::Action::Builtin::HandleBox do
|
||||||
it "adds a box using any format the provider allows" do
|
it "adds a box using any format the provider allows" do
|
||||||
machine.provider_options[:box_format] = [:foo, :bar]
|
machine.provider_options[:box_format] = [:foo, :bar]
|
||||||
|
|
||||||
expect(action_runner).to receive(:run).with { |action, opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, opts|
|
||||||
expect(opts[:box_name]).to eq(machine.config.vm.box)
|
expect(opts[:box_name]).to eq(machine.config.vm.box)
|
||||||
expect(opts[:box_url]).to eq(machine.config.vm.box)
|
expect(opts[:box_url]).to eq(machine.config.vm.box)
|
||||||
expect(opts[:box_provider]).to eq([:foo, :bar])
|
expect(opts[:box_provider]).to eq([:foo, :bar])
|
||||||
|
@ -86,14 +86,14 @@ describe Vagrant::Action::Builtin::HandleBox do
|
||||||
|
|
||||||
context "with a box and box_url set" do
|
context "with a box and box_url set" do
|
||||||
before do
|
before do
|
||||||
machine.stub(box: nil)
|
allow(machine).to receive(:box).and_return(nil)
|
||||||
|
|
||||||
machine.config.vm.box = "foo"
|
machine.config.vm.box = "foo"
|
||||||
machine.config.vm.box_url = "bar"
|
machine.config.vm.box_url = "bar"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds a box that doesn't exist" do
|
it "adds a box that doesn't exist" do
|
||||||
expect(action_runner).to receive(:run).with { |action, opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, opts|
|
||||||
expect(opts[:box_name]).to eq(machine.config.vm.box)
|
expect(opts[:box_name]).to eq(machine.config.vm.box)
|
||||||
expect(opts[:box_url]).to eq(machine.config.vm.box_url)
|
expect(opts[:box_url]).to eq(machine.config.vm.box_url)
|
||||||
expect(opts[:box_provider]).to eq(:dummy)
|
expect(opts[:box_provider]).to eq(:dummy)
|
||||||
|
@ -109,7 +109,7 @@ describe Vagrant::Action::Builtin::HandleBox do
|
||||||
|
|
||||||
context "with a box with a checksum set" do
|
context "with a box with a checksum set" do
|
||||||
before do
|
before do
|
||||||
machine.stub(box: nil)
|
allow(machine).to receive(:box).and_return(nil)
|
||||||
|
|
||||||
machine.config.vm.box = "foo"
|
machine.config.vm.box = "foo"
|
||||||
machine.config.vm.box_url = "bar"
|
machine.config.vm.box_url = "bar"
|
||||||
|
@ -118,7 +118,7 @@ describe Vagrant::Action::Builtin::HandleBox do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds a box that doesn't exist and maps checksum options correctly" do
|
it "adds a box that doesn't exist and maps checksum options correctly" do
|
||||||
expect(action_runner).to receive(:run).with { |action, opts|
|
expect(action_runner).to receive(:run).with(any_args) { |action, opts|
|
||||||
expect(opts[:box_name]).to eq(machine.config.vm.box)
|
expect(opts[:box_name]).to eq(machine.config.vm.box)
|
||||||
expect(opts[:box_url]).to eq(machine.config.vm.box_url)
|
expect(opts[:box_url]).to eq(machine.config.vm.box_url)
|
||||||
expect(opts[:box_provider]).to eq(:dummy)
|
expect(opts[:box_provider]).to eq(:dummy)
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe Vagrant::Action::Builtin::HandleForwardedPortCollisions do
|
||||||
|
|
||||||
let(:machine_config) do
|
let(:machine_config) do
|
||||||
double("machine_config").tap do |config|
|
double("machine_config").tap do |config|
|
||||||
config.stub(vm: vm_config)
|
allow(config).to receive(:vm).and_return(vm_config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe Vagrant::Action::Builtin::IsEnvSet do
|
||||||
expect(app).to receive(:call).with(env)
|
expect(app).to receive(:call).with(env)
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
expect(env[:result]).to be_true
|
expect(env[:result]).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets result to false if it isn't set" do
|
it "sets result to false if it isn't set" do
|
||||||
|
@ -25,7 +25,7 @@ describe Vagrant::Action::Builtin::IsEnvSet do
|
||||||
expect(app).to receive(:call).with(env)
|
expect(app).to receive(:call).with(env)
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
expect(env[:result]).to be_false
|
expect(env[:result]).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,36 +16,36 @@ describe Vagrant::Action::Builtin::IsState do
|
||||||
|
|
||||||
describe "#call" do
|
describe "#call" do
|
||||||
it "sets result to false if is proper state" do
|
it "sets result to false if is proper state" do
|
||||||
state.stub(id: :foo)
|
allow(state).to receive(:id).and_return(:foo)
|
||||||
|
|
||||||
subject = described_class.new(app, env, :bar)
|
subject = described_class.new(app, env, :bar)
|
||||||
|
|
||||||
expect(app).to receive(:call).with(env)
|
expect(app).to receive(:call).with(env)
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
expect(env[:result]).to be_false
|
expect(env[:result]).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets result to true if is proper state" do
|
it "sets result to true if is proper state" do
|
||||||
state.stub(id: :foo)
|
allow(state).to receive(:id).and_return(:foo)
|
||||||
|
|
||||||
subject = described_class.new(app, env, :foo)
|
subject = described_class.new(app, env, :foo)
|
||||||
|
|
||||||
expect(app).to receive(:call).with(env)
|
expect(app).to receive(:call).with(env)
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
expect(env[:result]).to be_true
|
expect(env[:result]).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "inverts the result if specified" do
|
it "inverts the result if specified" do
|
||||||
state.stub(id: :foo)
|
allow(state).to receive(:id).and_return(:foo)
|
||||||
|
|
||||||
subject = described_class.new(app, env, :foo, invert: true)
|
subject = described_class.new(app, env, :foo, invert: true)
|
||||||
|
|
||||||
expect(app).to receive(:call).with(env)
|
expect(app).to receive(:call).with(env)
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
expect(env[:result]).to be_false
|
expect(env[:result]).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
|
||||||
|
|
||||||
let(:machine_config) do
|
let(:machine_config) do
|
||||||
double("machine_config").tap do |top_config|
|
double("machine_config").tap do |top_config|
|
||||||
top_config.stub(vm: vm_config)
|
allow(top_config).to receive(:vm).and_return(vm_config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -98,8 +98,8 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
|
||||||
plugins[:default] = [impl(true, "default"), 10]
|
plugins[:default] = [impl(true, "default"), 10]
|
||||||
plugins[:nfs] = [impl(true, "nfs"), 5]
|
plugins[:nfs] = [impl(true, "nfs"), 5]
|
||||||
|
|
||||||
subject.stub(plugins: plugins)
|
allow(subject).to receive(:plugins).and_return(plugins)
|
||||||
vm_config.stub(synced_folders: folders)
|
allow(vm_config).to receive(:synced_folders).and_return(folders)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should raise exception if bad type is given" do
|
it "should raise exception if bad type is given" do
|
||||||
|
@ -133,7 +133,7 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
|
||||||
|
|
||||||
other_folders = { "bar" => {} }
|
other_folders = { "bar" => {} }
|
||||||
other = double("config")
|
other = double("config")
|
||||||
other.stub(synced_folders: other_folders)
|
allow(other).to receive(:synced_folders).and_return(other_folders)
|
||||||
|
|
||||||
result = subject.synced_folders(machine, config: other)
|
result = subject.synced_folders(machine, config: other)
|
||||||
expect(result.length).to eq(1)
|
expect(result.length).to eq(1)
|
||||||
|
@ -147,7 +147,7 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
|
||||||
folders["root"] = { type: "unusable" }
|
folders["root"] = { type: "unusable" }
|
||||||
|
|
||||||
expect { subject.synced_folders(machine) }.
|
expect { subject.synced_folders(machine) }.
|
||||||
to raise_error
|
to raise_error(RuntimeError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should ignore disabled folders" do
|
it "should ignore disabled folders" do
|
||||||
|
@ -201,7 +201,7 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
|
||||||
it "should be able to save and retrieve cached versions" do
|
it "should be able to save and retrieve cached versions" do
|
||||||
other_folders = {}
|
other_folders = {}
|
||||||
other = double("config")
|
other = double("config")
|
||||||
other.stub(synced_folders: other_folders)
|
allow(other).to receive(:synced_folders).and_return(other_folders)
|
||||||
|
|
||||||
other_folders["foo"] = { type: "default" }
|
other_folders["foo"] = { type: "default" }
|
||||||
result = subject.synced_folders(machine, config: other)
|
result = subject.synced_folders(machine, config: other)
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe Vagrant::Action::Builtin::Provision do
|
||||||
|
|
||||||
let(:machine_config) do
|
let(:machine_config) do
|
||||||
double("machine_config").tap do |config|
|
double("machine_config").tap do |config|
|
||||||
config.stub(vm: vm_config)
|
allow(config).to receive(:vm).and_return(vm_config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe Vagrant::Action::Builtin::ProvisionerCleanup do
|
||||||
|
|
||||||
let(:machine_config) do
|
let(:machine_config) do
|
||||||
double("machine_config").tap do |config|
|
double("machine_config").tap do |config|
|
||||||
config.stub(vm: vm_config)
|
allow(config).to receive(:vm).and_return(vm_config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe Vagrant::Action::Builtin::SyncedFolderCleanup do
|
||||||
|
|
||||||
let(:machine_config) do
|
let(:machine_config) do
|
||||||
double("machine_config").tap do |top_config|
|
double("machine_config").tap do |top_config|
|
||||||
top_config.stub(vm: vm_config)
|
allow(top_config).to receive(:vm).and_return(vm_config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ describe Vagrant::Action::Builtin::SyncedFolderCleanup do
|
||||||
env[:machine] = Object.new
|
env[:machine] = Object.new
|
||||||
env[:root_path] = Pathname.new(Dir.mktmpdir("vagrant-test-synced-folder-cleanup-call"))
|
env[:root_path] = Pathname.new(Dir.mktmpdir("vagrant-test-synced-folder-cleanup-call"))
|
||||||
|
|
||||||
subject.stub(plugins: plugins)
|
allow(subject).to receive(:plugins).and_return(plugins)
|
||||||
subject.stub(synced_folders: synced_folders)
|
allow(subject).to receive(:synced_folders).and_return(synced_folders)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -131,9 +131,9 @@ describe Vagrant::Action::Builtin::SyncedFolderCleanup do
|
||||||
|
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
|
|
||||||
expect(trackers[0].clean).to be_true
|
expect(trackers[0].clean).to be(true)
|
||||||
expect(trackers[1].clean).to be_true
|
expect(trackers[1].clean).to be(true)
|
||||||
expect(trackers[2].clean).to be_true
|
expect(trackers[2].clean).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe Vagrant::Action::Builtin::SyncedFolders do
|
||||||
|
|
||||||
let(:machine_config) do
|
let(:machine_config) do
|
||||||
double("machine_config").tap do |top_config|
|
double("machine_config").tap do |top_config|
|
||||||
top_config.stub(vm: vm_config)
|
allow(top_config).to receive(:vm).and_return(vm_config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ describe Vagrant::Action::Builtin::SyncedFolders do
|
||||||
plugins[:nfs] = [impl(true, "nfs"), 5]
|
plugins[:nfs] = [impl(true, "nfs"), 5]
|
||||||
|
|
||||||
env[:root_path] = Pathname.new(Dir.mktmpdir("vagrant-test-synced-folders-call"))
|
env[:root_path] = Pathname.new(Dir.mktmpdir("vagrant-test-synced-folders-call"))
|
||||||
subject.stub(plugins: plugins)
|
allow(subject).to receive(:plugins).and_return(plugins)
|
||||||
subject.stub(synced_folders: synced_folders)
|
allow(subject).to receive(:synced_folders).and_return(synced_folders)
|
||||||
allow(subject).to receive(:save_synced_folders)
|
allow(subject).to receive(:save_synced_folders)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ describe Vagrant::BatchAction do
|
||||||
|
|
||||||
def new_machine(options)
|
def new_machine(options)
|
||||||
double("machine").tap do |m|
|
double("machine").tap do |m|
|
||||||
m.stub(provider_name: provider_name)
|
allow(m).to receive(:provider_name).and_return(provider_name)
|
||||||
m.stub(provider_options: options)
|
allow(m).to receive(:provider_options).and_return(options)
|
||||||
allow(m).to receive(:action) do |action, opts|
|
allow(m).to receive(:action) do |action, opts|
|
||||||
lock.synchronize do
|
lock.synchronize do
|
||||||
called_actions << [m, action, opts]
|
called_actions << [m, action, opts]
|
||||||
|
|
|
@ -223,7 +223,7 @@ describe Vagrant::BoxCollection, :skip_windows do
|
||||||
environment.box3("foo", "0", :virtualbox,
|
environment.box3("foo", "0", :virtualbox,
|
||||||
metadata_url: "foourl")
|
metadata_url: "foourl")
|
||||||
|
|
||||||
expect(hook).to receive(:call).with { |name, env|
|
expect(hook).to receive(:call).with(any_args) { |name, env|
|
||||||
expect(name).to eq(:authenticate_box_url)
|
expect(name).to eq(:authenticate_box_url)
|
||||||
expect(env[:box_urls]).to eq(["foourl"])
|
expect(env[:box_urls]).to eq(["foourl"])
|
||||||
true
|
true
|
||||||
|
|
|
@ -110,7 +110,7 @@ describe Vagrant::Box, :skip_windows do
|
||||||
}
|
}
|
||||||
RAW
|
RAW
|
||||||
|
|
||||||
subject.stub(load_metadata: metadata)
|
allow(subject).to receive(:load_metadata).and_return(metadata)
|
||||||
|
|
||||||
expect(subject.has_update?).to be_nil
|
expect(subject.has_update?).to be_nil
|
||||||
end
|
end
|
||||||
|
@ -136,7 +136,7 @@ describe Vagrant::Box, :skip_windows do
|
||||||
}
|
}
|
||||||
RAW
|
RAW
|
||||||
|
|
||||||
subject.stub(load_metadata: metadata)
|
allow(subject).to receive(:load_metadata).and_return(metadata)
|
||||||
|
|
||||||
result = subject.has_update?
|
result = subject.has_update?
|
||||||
expect(result).to_not be_nil
|
expect(result).to_not be_nil
|
||||||
|
@ -180,7 +180,7 @@ describe Vagrant::Box, :skip_windows do
|
||||||
}
|
}
|
||||||
RAW
|
RAW
|
||||||
|
|
||||||
subject.stub(load_metadata: metadata)
|
allow(subject).to receive(:load_metadata).and_return(metadata)
|
||||||
|
|
||||||
result = subject.has_update?(">= 1.1, < 1.4")
|
result = subject.has_update?(">= 1.1, < 1.4")
|
||||||
expect(result).to_not be_nil
|
expect(result).to_not be_nil
|
||||||
|
@ -256,8 +256,8 @@ describe Vagrant::Box, :skip_windows do
|
||||||
|
|
||||||
it "raises an error if the download failed" do
|
it "raises an error if the download failed" do
|
||||||
dl = double("downloader")
|
dl = double("downloader")
|
||||||
Vagrant::Util::Downloader.stub(new: dl)
|
allow(Vagrant::Util::Downloader).to receive(:new).and_return(dl)
|
||||||
dl.should_receive(:download!).and_raise(
|
expect(dl).to receive(:download!).and_raise(
|
||||||
Vagrant::Errors::DownloaderError.new(message: "foo"))
|
Vagrant::Errors::DownloaderError.new(message: "foo"))
|
||||||
|
|
||||||
expect { subject.load_metadata }.
|
expect { subject.load_metadata }.
|
||||||
|
@ -308,7 +308,7 @@ describe Vagrant::Box, :skip_windows do
|
||||||
end
|
end
|
||||||
|
|
||||||
# Repackage our box to some temporary directory
|
# Repackage our box to some temporary directory
|
||||||
expect(subject.repackage(box_output_path)).to be_true
|
expect(subject.repackage(box_output_path)).to be(true)
|
||||||
|
|
||||||
# Let's now add this box again under a different name, and then
|
# Let's now add this box again under a different name, and then
|
||||||
# verify that we get the proper result back.
|
# verify that we get the proper result back.
|
||||||
|
|
|
@ -104,15 +104,15 @@ describe Vagrant::CapabilityHost do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not have a non-existent capability" do
|
it "does not have a non-existent capability" do
|
||||||
expect(subject.capability?(:foo)).to be_false
|
expect(subject.capability?(:foo)).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has capabilities of itself" do
|
it "has capabilities of itself" do
|
||||||
expect(subject.capability?(:self)).to be_true
|
expect(subject.capability?(:self)).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has capabilities of parent" do
|
it "has capabilities of parent" do
|
||||||
expect(subject.capability?(:parent)).to be_true
|
expect(subject.capability?(:parent)).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe Vagrant::CLI do
|
||||||
let(:env) { iso_env.create_vagrant_env }
|
let(:env) { iso_env.create_vagrant_env }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant.plugin("2").manager.stub(commands: commands)
|
allow(Vagrant.plugin("2").manager).to receive(:commands).and_return(commands)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#execute" do
|
describe "#execute" do
|
||||||
|
@ -45,10 +45,10 @@ describe Vagrant::CLI do
|
||||||
commands[:bar] = [command_lambda("bar", 0), { primary: true }]
|
commands[:bar] = [command_lambda("bar", 0), { primary: true }]
|
||||||
commands[:baz] = [command_lambda("baz", 0), { primary: false }]
|
commands[:baz] = [command_lambda("baz", 0), { primary: false }]
|
||||||
|
|
||||||
expect(env.ui).to receive(:info).with { |message, opts|
|
expect(env.ui).to receive(:info).with(any_args) { |message, opts|
|
||||||
expect(message).to include("foo")
|
expect(message).to include("foo")
|
||||||
expect(message).to include("bar")
|
expect(message).to include("bar")
|
||||||
expect(message.include?("baz")).to be_false
|
expect(message.include?("baz")).to be(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
subject.help
|
subject.help
|
||||||
|
|
|
@ -31,8 +31,8 @@ describe Vagrant::Environment do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
m = Vagrant.plugin("2").manager
|
m = Vagrant.plugin("2").manager
|
||||||
m.stub(hosts: plugin_hosts)
|
allow(m).to receive(:hosts).and_return(plugin_hosts)
|
||||||
m.stub(host_capabilities: plugin_host_caps)
|
allow(m).to receive(:host_capabilities).and_return(plugin_host_caps)
|
||||||
|
|
||||||
# Detect the host
|
# Detect the host
|
||||||
env.vagrantfile <<-VF
|
env.vagrantfile <<-VF
|
||||||
|
@ -48,8 +48,8 @@ describe Vagrant::Environment do
|
||||||
it "should return whether it can install or not" do
|
it "should return whether it can install or not" do
|
||||||
plugin_host_caps[:foo] = { provider_install_foo: Class }
|
plugin_host_caps[:foo] = { provider_install_foo: Class }
|
||||||
|
|
||||||
expect(subject.can_install_provider?(:foo)).to be_true
|
expect(subject.can_install_provider?(:foo)).to be(true)
|
||||||
expect(subject.can_install_provider?(:bar)).to be_false
|
expect(subject.can_install_provider?(:bar)).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -160,7 +160,8 @@ describe Vagrant::Environment do
|
||||||
|
|
||||||
it "moves the boxes into the new directory structure" do
|
it "moves the boxes into the new directory structure" do
|
||||||
# Kind of hacky but avoids two instantiations of BoxCollection
|
# Kind of hacky but avoids two instantiations of BoxCollection
|
||||||
Vagrant::Environment.any_instance.stub(boxes: double("boxes"))
|
allow(Vagrant::Environment).to receive(:boxes)
|
||||||
|
.and_return(double("boxes"))
|
||||||
|
|
||||||
collection = double("collection")
|
collection = double("collection")
|
||||||
expect(Vagrant::BoxCollection).to receive(:new).with(
|
expect(Vagrant::BoxCollection).to receive(:new).with(
|
||||||
|
@ -177,8 +178,8 @@ describe Vagrant::Environment do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
m = Vagrant.plugin("2").manager
|
m = Vagrant.plugin("2").manager
|
||||||
m.stub(hosts: plugin_hosts)
|
allow(m).to receive(:hosts).and_return(plugin_hosts)
|
||||||
m.stub(host_capabilities: plugin_host_caps)
|
allow(m).to receive(:host_capabilities).and_return(plugin_host_caps)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should default to some host even if there are none" do
|
it "should default to some host even if there are none" do
|
||||||
|
@ -202,7 +203,7 @@ describe Vagrant::Environment do
|
||||||
plugin_host_caps[:foo] = { bar: Class }
|
plugin_host_caps[:foo] = { bar: Class }
|
||||||
|
|
||||||
result = subject.host
|
result = subject.host
|
||||||
expect(result.capability?(:bar)).to be_true
|
expect(result.capability?(:bar)).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should attempt to detect a host if host is :detect" do
|
it "should attempt to detect a host if host is :detect" do
|
||||||
|
@ -216,7 +217,7 @@ describe Vagrant::Environment do
|
||||||
plugin_host_caps[:foo] = { bar: Class }
|
plugin_host_caps[:foo] = { bar: Class }
|
||||||
|
|
||||||
result = subject.host
|
result = subject.host
|
||||||
expect(result.capability?(:bar)).to be_true
|
expect(result.capability?(:bar)).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use an exact host if specified" do
|
it "should use an exact host if specified" do
|
||||||
|
@ -231,7 +232,7 @@ describe Vagrant::Environment do
|
||||||
plugin_host_caps[:foo] = { bar: Class }
|
plugin_host_caps[:foo] = { bar: Class }
|
||||||
|
|
||||||
result = subject.host
|
result = subject.host
|
||||||
expect(result.capability?(:bar)).to be_true
|
expect(result.capability?(:bar)).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should raise an error if an exact match was specified but not found" do
|
it "should raise an error if an exact match was specified but not found" do
|
||||||
|
@ -270,7 +271,7 @@ describe Vagrant::Environment do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(raised).to be_true
|
expect(raised).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows nested locks on the same environment" do
|
it "allows nested locks on the same environment" do
|
||||||
|
@ -282,7 +283,7 @@ describe Vagrant::Environment do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(success).to be_true
|
expect(success).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "cleans up all lock files" do
|
it "cleans up all lock files" do
|
||||||
|
@ -641,8 +642,8 @@ VF
|
||||||
klass = double("machine_index")
|
klass = double("machine_index")
|
||||||
stub_const("Vagrant::MachineIndex", klass)
|
stub_const("Vagrant::MachineIndex", klass)
|
||||||
|
|
||||||
klass.should_receive(:new).with do |path|
|
expect(klass).to receive(:new).with(any_args) do |path|
|
||||||
expect(path.to_s.start_with?(subject.home_path.to_s)).to be_true
|
expect(path.to_s.start_with?(subject.home_path.to_s)).to be(true)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -759,7 +760,7 @@ VF
|
||||||
|
|
||||||
before do
|
before do
|
||||||
m = Vagrant.plugin("2").manager
|
m = Vagrant.plugin("2").manager
|
||||||
m.stub(providers: plugin_providers)
|
allow(m).to receive(:providers).and_return(plugin_providers)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is the highest matching usable provider" do
|
it "is the highest matching usable provider" do
|
||||||
|
@ -985,7 +986,7 @@ VF
|
||||||
Dir.chdir(temp_dir) do
|
Dir.chdir(temp_dir) do
|
||||||
instance = described_class.new(local_data_path: "foo")
|
instance = described_class.new(local_data_path: "foo")
|
||||||
expect(instance.local_data_path).to eq(instance.cwd.join("foo"))
|
expect(instance.local_data_path).to eq(instance.cwd.join("foo"))
|
||||||
expect(File.exist?(instance.local_data_path)).to be_false
|
expect(File.exist?(instance.local_data_path)).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1249,7 +1250,7 @@ VF
|
||||||
|
|
||||||
env = environment.create_vagrant_env
|
env = environment.create_vagrant_env
|
||||||
env.push("foo")
|
env.push("foo")
|
||||||
expect(push_class.pushed?).to be_true
|
expect(push_class.pushed?).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1257,7 +1258,7 @@ VF
|
||||||
it "should call the action runner with the proper hook" do
|
it "should call the action runner with the proper hook" do
|
||||||
hook_name = :foo
|
hook_name = :foo
|
||||||
|
|
||||||
expect(instance.action_runner).to receive(:run).with { |callable, env|
|
expect(instance.action_runner).to receive(:run).with(any_args) { |callable, env|
|
||||||
expect(env[:action_name]).to eq(hook_name)
|
expect(env[:action_name]).to eq(hook_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,7 +1280,7 @@ VF
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should allow passing in custom data" do
|
it "should allow passing in custom data" do
|
||||||
expect(instance.action_runner).to receive(:run).with { |callable, env|
|
expect(instance.action_runner).to receive(:run).with(any_args) { |callable, env|
|
||||||
expect(env[:foo]).to eq(:bar)
|
expect(env[:foo]).to eq(:bar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1287,7 +1288,7 @@ VF
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should allow passing a custom callable" do
|
it "should allow passing a custom callable" do
|
||||||
expect(instance.action_runner).to receive(:run).with { |callable, env|
|
expect(instance.action_runner).to receive(:run).with(any_args) { |callable, env|
|
||||||
expect(callable).to eq(:what)
|
expect(callable).to eq(:what)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,10 @@ describe Vagrant::Guest do
|
||||||
let(:guests) { {} }
|
let(:guests) { {} }
|
||||||
let(:machine) do
|
let(:machine) do
|
||||||
double("machine").tap do |m|
|
double("machine").tap do |m|
|
||||||
m.stub(inspect: "machine")
|
allow(m).to receive(:inspect).and_return("machine")
|
||||||
m.stub(config: double("config"))
|
allow(m).to receive(:config).and_return(double("config"))
|
||||||
m.config.stub(vm: double("vm_config"))
|
allow(m.config).to receive(:vm).and_return(double("vm_config"))
|
||||||
m.config.vm.stub(guest: nil)
|
allow(m.config.vm).to receive(:guest).and_return(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ describe Vagrant::Guest do
|
||||||
|
|
||||||
describe "#detect!" do
|
describe "#detect!" do
|
||||||
it "auto-detects if no explicit guest name given" do
|
it "auto-detects if no explicit guest name given" do
|
||||||
machine.config.vm.stub(guest: nil)
|
allow(machine.config.vm).to receive(:guest).and_return(nil)
|
||||||
expect(subject).to receive(:initialize_capabilities!).
|
expect(subject).to receive(:initialize_capabilities!).
|
||||||
with(nil, guests, capabilities, machine)
|
with(nil, guests, capabilities, machine)
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ describe Vagrant::Guest do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses the explicit guest name if specified" do
|
it "uses the explicit guest name if specified" do
|
||||||
machine.config.vm.stub(guest: :foo)
|
allow(machine.config.vm).to receive(:guest).and_return(:foo)
|
||||||
expect(subject).to receive(:initialize_capabilities!).
|
expect(subject).to receive(:initialize_capabilities!).
|
||||||
with(:foo, guests, capabilities, machine)
|
with(:foo, guests, capabilities, machine)
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ describe Vagrant::Guest do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises a user-friendly error if specified guest doesn't exist" do
|
it "raises a user-friendly error if specified guest doesn't exist" do
|
||||||
machine.config.vm.stub(guest: :foo)
|
allow(machine.config.vm).to receive(:guest).and_return(:foo)
|
||||||
|
|
||||||
expect { subject.detect! }.
|
expect { subject.detect! }.
|
||||||
to raise_error(Vagrant::Errors::GuestExplicitNotDetected)
|
to raise_error(Vagrant::Errors::GuestExplicitNotDetected)
|
||||||
|
|
|
@ -136,7 +136,7 @@ describe Vagrant::MachineIndex do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should include? by prefix" do
|
it "should include? by prefix" do
|
||||||
expect(subject.include?("b")).to be_true
|
expect(subject.include?("b")).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "locks the entry so subsequent gets fail" do
|
it "locks the entry so subsequent gets fail" do
|
||||||
|
@ -159,7 +159,7 @@ describe Vagrant::MachineIndex do
|
||||||
|
|
||||||
describe "#include" do
|
describe "#include" do
|
||||||
it "should not include non-existent things" do
|
it "should not include non-existent things" do
|
||||||
expect(subject.include?("foo")).to be_false
|
expect(subject.include?("foo")).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should include created entries" do
|
it "should include created entries" do
|
||||||
|
@ -168,7 +168,7 @@ describe Vagrant::MachineIndex do
|
||||||
subject.release(result)
|
subject.release(result)
|
||||||
|
|
||||||
subject = described_class.new(data_dir)
|
subject = described_class.new(data_dir)
|
||||||
expect(subject.include?(result.id)).to be_true
|
expect(subject.include?(result.id)).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ describe Vagrant::MachineIndex do
|
||||||
|
|
||||||
it "can delete an entry that doesn't exist" do
|
it "can delete an entry that doesn't exist" do
|
||||||
e = entry_klass.new
|
e = entry_klass.new
|
||||||
expect(subject.delete(e)).to be_true
|
expect(subject.delete(e)).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "updates an existing entry" do
|
it "updates an existing entry" do
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe Vagrant::Machine do
|
||||||
let(:provider) { new_provider_mock }
|
let(:provider) { new_provider_mock }
|
||||||
let(:provider_cls) do
|
let(:provider_cls) do
|
||||||
obj = double("provider_cls")
|
obj = double("provider_cls")
|
||||||
obj.stub(new: provider)
|
allow(obj).to receive(:new).and_return(provider)
|
||||||
obj
|
obj
|
||||||
end
|
end
|
||||||
let(:provider_config) { Object.new }
|
let(:provider_config) { Object.new }
|
||||||
|
@ -21,9 +21,9 @@ describe Vagrant::Machine do
|
||||||
let(:base) { false }
|
let(:base) { false }
|
||||||
let(:box) do
|
let(:box) do
|
||||||
double("box").tap do |b|
|
double("box").tap do |b|
|
||||||
b.stub(name: "foo")
|
allow(b).to receive(:name).and_return("foo")
|
||||||
b.stub(provider: :dummy)
|
allow(b).to receive(:provider).and_return(:dummy)
|
||||||
b.stub(version: "1.0")
|
allow(b).to receive(:version).and_return("1.0")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ describe Vagrant::Machine do
|
||||||
|
|
||||||
def new_provider_mock
|
def new_provider_mock
|
||||||
double("provider").tap do |obj|
|
double("provider").tap do |obj|
|
||||||
obj.stub(_initialize: nil)
|
allow(obj).to receive(:_initialize).and_return(nil)
|
||||||
obj.stub(machine_id_changed: nil)
|
allow(obj).to receive(:machine_id_changed).and_return(nil)
|
||||||
allow(obj).to receive(:state).and_return(Vagrant::MachineState.new(
|
allow(obj).to receive(:state).and_return(Vagrant::MachineState.new(
|
||||||
:created, "", ""))
|
:created, "", ""))
|
||||||
end
|
end
|
||||||
|
@ -81,7 +81,7 @@ describe Vagrant::Machine do
|
||||||
|
|
||||||
it "should not insert key" do
|
it "should not insert key" do
|
||||||
subject = new_instance
|
subject = new_instance
|
||||||
expect(subject.config.ssh.insert_key).to be_false
|
expect(subject.config.ssh.insert_key).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ describe Vagrant::Machine do
|
||||||
|
|
||||||
it "should initialize the capabilities" do
|
it "should initialize the capabilities" do
|
||||||
instance = new_provider_mock
|
instance = new_provider_mock
|
||||||
expect(instance).to receive(:_initialize).with { |p, m|
|
expect(instance).to receive(:_initialize).with(any_args) { |p, m|
|
||||||
expect(p).to eq(provider_name)
|
expect(p).to eq(provider_name)
|
||||||
expect(m.name).to eq(name)
|
expect(m.name).to eq(name)
|
||||||
true
|
true
|
||||||
|
@ -383,7 +383,7 @@ describe Vagrant::Machine do
|
||||||
it "should run the callable with the proper env" do
|
it "should run the callable with the proper env" do
|
||||||
subject.action_raw(:foo, callable)
|
subject.action_raw(:foo, callable)
|
||||||
|
|
||||||
expect(@env[:called]).to be_true
|
expect(@env[:called]).to be(true)
|
||||||
expect(@env[:action_name]).to eq(:machine_action_foo)
|
expect(@env[:action_name]).to eq(:machine_action_foo)
|
||||||
expect(@env[:machine]).to equal(subject)
|
expect(@env[:machine]).to equal(subject)
|
||||||
expect(@env[:machine_action]).to eq(:foo)
|
expect(@env[:machine_action]).to eq(:foo)
|
||||||
|
@ -398,7 +398,7 @@ describe Vagrant::Machine do
|
||||||
it "should merge in any extra env" do
|
it "should merge in any extra env" do
|
||||||
subject.action_raw(:bar, callable, foo: :bar)
|
subject.action_raw(:bar, callable, foo: :bar)
|
||||||
|
|
||||||
expect(@env[:called]).to be_true
|
expect(@env[:called]).to be(true)
|
||||||
expect(@env[:foo]).to eq(:bar)
|
expect(@env[:foo]).to eq(:bar)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -533,9 +533,9 @@ describe Vagrant::Machine do
|
||||||
|
|
||||||
# Setup the box information
|
# Setup the box information
|
||||||
box = double("box")
|
box = double("box")
|
||||||
box.stub(name: "foo")
|
allow(box).to receive(:name).and_return("foo")
|
||||||
box.stub(provider: :bar)
|
allow(box).to receive(:provider).and_return(:bar)
|
||||||
box.stub(version: "1.2.3")
|
allow(box).to receive(:version).and_return("1.2.3")
|
||||||
subject.box = box
|
subject.box = box
|
||||||
|
|
||||||
subject.id = "foo"
|
subject.id = "foo"
|
||||||
|
@ -788,18 +788,18 @@ describe Vagrant::Machine do
|
||||||
|
|
||||||
context "with custom ssh_info" do
|
context "with custom ssh_info" do
|
||||||
it "keys_only should be default" do
|
it "keys_only should be default" do
|
||||||
expect(instance.ssh_info[:keys_only]).to be_true
|
expect(instance.ssh_info[:keys_only]).to be(true)
|
||||||
end
|
end
|
||||||
it "paranoid should be default" do
|
it "paranoid should be default" do
|
||||||
expect(instance.ssh_info[:paranoid]).to be_false
|
expect(instance.ssh_info[:paranoid]).to be(false)
|
||||||
end
|
end
|
||||||
it "keys_only should be overridden" do
|
it "keys_only should be overridden" do
|
||||||
instance.config.ssh.keys_only = false
|
instance.config.ssh.keys_only = false
|
||||||
expect(instance.ssh_info[:keys_only]).to be_false
|
expect(instance.ssh_info[:keys_only]).to be(false)
|
||||||
end
|
end
|
||||||
it "paranoid should be overridden" do
|
it "paranoid should be overridden" do
|
||||||
instance.config.ssh.paranoid = true
|
instance.config.ssh.paranoid = true
|
||||||
expect(instance.ssh_info[:paranoid]).to be_true
|
expect(instance.ssh_info[:paranoid]).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe Vagrant::Plugin::Manager do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Vagrant::Bundler.stub(instance: bundler)
|
allow(Vagrant::Bundler).to receive(:instance).and_return(bundler)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(path) }
|
subject { described_class.new(path) }
|
||||||
|
@ -30,9 +30,9 @@ describe Vagrant::Plugin::Manager do
|
||||||
it "installs the plugin and adds it to the state file" do
|
it "installs the plugin and adds it to the state file" do
|
||||||
specs = Array.new(5) { Gem::Specification.new }
|
specs = Array.new(5) { Gem::Specification.new }
|
||||||
specs[3].name = "foo"
|
specs[3].name = "foo"
|
||||||
expect(bundler).to receive(:install).once.with { |plugins, local|
|
expect(bundler).to receive(:install).once.with(any_args) { |plugins, local|
|
||||||
expect(plugins).to have_key("foo")
|
expect(plugins).to have_key("foo")
|
||||||
expect(local).to be_false
|
expect(local).to be(false)
|
||||||
}.and_return(specs)
|
}.and_return(specs)
|
||||||
expect(bundler).to receive(:clean)
|
expect(bundler).to receive(:clean)
|
||||||
|
|
||||||
|
@ -92,10 +92,10 @@ describe Vagrant::Plugin::Manager do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs a version with constraints" do
|
it "installs a version with constraints" do
|
||||||
expect(bundler).to receive(:install).once.with { |plugins, local|
|
expect(bundler).to receive(:install).once.with(any_args) { |plugins, local|
|
||||||
expect(plugins).to have_key("foo")
|
expect(plugins).to have_key("foo")
|
||||||
expect(plugins["foo"]["gem_version"]).to eql(">= 0.1.0")
|
expect(plugins["foo"]["gem_version"]).to eql(">= 0.1.0")
|
||||||
expect(local).to be_false
|
expect(local).to be(false)
|
||||||
}.and_return(specs)
|
}.and_return(specs)
|
||||||
expect(bundler).to receive(:clean)
|
expect(bundler).to receive(:clean)
|
||||||
|
|
||||||
|
@ -107,10 +107,10 @@ describe Vagrant::Plugin::Manager do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs with an exact version but doesn't constrain" do
|
it "installs with an exact version but doesn't constrain" do
|
||||||
expect(bundler).to receive(:install).once.with { |plugins, local|
|
expect(bundler).to receive(:install).once.with(any_args) { |plugins, local|
|
||||||
expect(plugins).to have_key("foo")
|
expect(plugins).to have_key("foo")
|
||||||
expect(plugins["foo"]["gem_version"]).to eql("0.1.0")
|
expect(plugins["foo"]["gem_version"]).to eql("0.1.0")
|
||||||
expect(local).to be_false
|
expect(local).to be(false)
|
||||||
}.and_return(specs)
|
}.and_return(specs)
|
||||||
expect(bundler).to receive(:clean)
|
expect(bundler).to receive(:clean)
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ describe Vagrant::Plugin::Manager do
|
||||||
before do
|
before do
|
||||||
systems_path.unlink
|
systems_path.unlink
|
||||||
|
|
||||||
described_class.stub(system_plugins_file: systems_path)
|
allow(described_class).to receive(:system_plugins_file).and_return(systems_path)
|
||||||
|
|
||||||
sf = Vagrant::Plugin::StateFile.new(systems_path)
|
sf = Vagrant::Plugin::StateFile.new(systems_path)
|
||||||
sf.add_plugin("foo", version: "0.2.0")
|
sf.add_plugin("foo", version: "0.2.0")
|
||||||
|
@ -170,7 +170,7 @@ describe Vagrant::Plugin::Manager do
|
||||||
subject.uninstall_plugin("bar")
|
subject.uninstall_plugin("bar")
|
||||||
|
|
||||||
plugins = subject.installed_plugins
|
plugins = subject.installed_plugins
|
||||||
expect(plugins["foo"]["system"]).to be_true
|
expect(plugins["foo"]["system"]).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if uninstalling a system gem" do
|
it "raises an error if uninstalling a system gem" do
|
||||||
|
@ -230,7 +230,7 @@ describe Vagrant::Plugin::Manager do
|
||||||
before do
|
before do
|
||||||
systems_path.unlink
|
systems_path.unlink
|
||||||
|
|
||||||
described_class.stub(system_plugins_file: systems_path)
|
allow(described_class).to receive(:system_plugins_file).and_return(systems_path)
|
||||||
|
|
||||||
sf = Vagrant::Plugin::StateFile.new(systems_path)
|
sf = Vagrant::Plugin::StateFile.new(systems_path)
|
||||||
sf.add_plugin("foo", version: "0.2.0")
|
sf.add_plugin("foo", version: "0.2.0")
|
||||||
|
@ -243,9 +243,9 @@ describe Vagrant::Plugin::Manager do
|
||||||
expect(plugins.length).to eql(2)
|
expect(plugins.length).to eql(2)
|
||||||
expect(plugins).to have_key("foo")
|
expect(plugins).to have_key("foo")
|
||||||
expect(plugins["foo"]["gem_version"]).to eq("0.1.0")
|
expect(plugins["foo"]["gem_version"]).to eq("0.1.0")
|
||||||
expect(plugins["foo"]["system"]).to be_true
|
expect(plugins["foo"]["system"]).to be_truthy
|
||||||
expect(plugins).to have_key("bar")
|
expect(plugins).to have_key("bar")
|
||||||
expect(plugins["bar"]["system"]).to be_true
|
expect(plugins["bar"]["system"]).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,9 +36,9 @@ describe Vagrant::Plugin::StateFile do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should check for plugins" do
|
it "should check for plugins" do
|
||||||
expect(subject.has_plugin?("foo")).to be_false
|
expect(subject.has_plugin?("foo")).to be(false)
|
||||||
subject.add_plugin("foo")
|
subject.add_plugin("foo")
|
||||||
expect(subject.has_plugin?("foo")).to be_true
|
expect(subject.has_plugin?("foo")).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should remove plugins" do
|
it "should remove plugins" do
|
||||||
|
|
|
@ -55,14 +55,14 @@ describe Vagrant::Plugin::V1::Command do
|
||||||
|
|
||||||
let(:environment) do
|
let(:environment) do
|
||||||
env = double("environment")
|
env = double("environment")
|
||||||
env.stub(root_path: "foo")
|
allow(env).to receive(:root_path).and_return("foo")
|
||||||
env
|
env
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:instance) { klass.new([], environment) }
|
let(:instance) { klass.new([], environment) }
|
||||||
|
|
||||||
it "should raise an exception if a root_path is not available" do
|
it "should raise an exception if a root_path is not available" do
|
||||||
environment.stub(root_path: nil)
|
allow(environment).to receive(:root_path).and_return(nil)
|
||||||
|
|
||||||
expect { instance.with_target_vms }.
|
expect { instance.with_target_vms }.
|
||||||
to raise_error(Vagrant::Errors::NoEnvironmentError)
|
to raise_error(Vagrant::Errors::NoEnvironmentError)
|
||||||
|
@ -75,9 +75,9 @@ describe Vagrant::Plugin::V1::Command do
|
||||||
bar_vm = double("bar")
|
bar_vm = double("bar")
|
||||||
allow(bar_vm).to receive(:name).and_return("bar")
|
allow(bar_vm).to receive(:name).and_return("bar")
|
||||||
|
|
||||||
environment.stub(multivm?: true,
|
allow(environment).to receive(:multivm?).and_return(true)
|
||||||
vms: { "foo" => foo_vm, "bar" => bar_vm },
|
allow(environment).to receive(:vms).and_return({ "foo" => foo_vm, "bar" => bar_vm })
|
||||||
vms_ordered: [foo_vm, bar_vm])
|
allow(environment).to receive(:vms_ordered).and_return([foo_vm, bar_vm])
|
||||||
|
|
||||||
vms = []
|
vms = []
|
||||||
instance.with_target_vms do |vm|
|
instance.with_target_vms do |vm|
|
||||||
|
@ -88,7 +88,8 @@ describe Vagrant::Plugin::V1::Command do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an exception if the named VM doesn't exist" do
|
it "raises an exception if the named VM doesn't exist" do
|
||||||
environment.stub(multivm?: true, vms: {})
|
allow(environment).to receive(:multivm?).and_return(true)
|
||||||
|
allow(environment).to receive(:vms).and_return({})
|
||||||
|
|
||||||
expect { instance.with_target_vms("foo") }.
|
expect { instance.with_target_vms("foo") }.
|
||||||
to raise_error(Vagrant::Errors::VMNotFoundError)
|
to raise_error(Vagrant::Errors::VMNotFoundError)
|
||||||
|
@ -98,8 +99,8 @@ describe Vagrant::Plugin::V1::Command do
|
||||||
foo_vm = double("foo")
|
foo_vm = double("foo")
|
||||||
allow(foo_vm).to receive(:name).and_return(:foo)
|
allow(foo_vm).to receive(:name).and_return(:foo)
|
||||||
|
|
||||||
environment.stub(multivm?: true,
|
allow(environment).to receive(:multivm?).and_return(true)
|
||||||
vms: { foo: foo_vm, bar: nil })
|
allow(environment).to receive(:vms).and_return({ foo: foo_vm, bar: nil })
|
||||||
|
|
||||||
vms = []
|
vms = []
|
||||||
instance.with_target_vms("foo") { |vm| vms << vm }
|
instance.with_target_vms("foo") { |vm| vms << vm }
|
||||||
|
|
|
@ -78,7 +78,7 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
subject { instance }
|
subject { instance }
|
||||||
|
|
||||||
it "should raise an exception if a root_path is not available" do
|
it "should raise an exception if a root_path is not available" do
|
||||||
environment.stub(root_path: nil)
|
allow(environment).to receive(:root_path).and_return(nil)
|
||||||
|
|
||||||
expect { instance.with_target_vms }.
|
expect { instance.with_target_vms }.
|
||||||
to raise_error(Vagrant::Errors::NoEnvironmentError)
|
to raise_error(Vagrant::Errors::NoEnvironmentError)
|
||||||
|
@ -86,16 +86,18 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
|
|
||||||
it "should yield every VM in order if no name is given" do
|
it "should yield every VM in order if no name is given" do
|
||||||
foo_vm = double("foo")
|
foo_vm = double("foo")
|
||||||
foo_vm.stub(name: "foo", provider: :foobarbaz)
|
allow(foo_vm).to receive(:name).and_return("foo")
|
||||||
foo_vm.stub(ui: Vagrant::UI::Silent.new)
|
allow(foo_vm).to receive(:provider).and_return(:foobarbaz)
|
||||||
foo_vm.stub(state: nil)
|
allow(foo_vm).to receive(:ui).and_return(Vagrant::UI::Silent.new)
|
||||||
|
allow(foo_vm).to receive(:state).and_return(nil)
|
||||||
|
|
||||||
bar_vm = double("bar")
|
bar_vm = double("bar")
|
||||||
bar_vm.stub(name: "bar", provider: :foobarbaz)
|
allow(bar_vm).to receive(:name).and_return("bar")
|
||||||
bar_vm.stub(ui: Vagrant::UI::Silent.new)
|
allow(bar_vm).to receive(:provider).and_return(:foobarbaz)
|
||||||
bar_vm.stub(state: nil)
|
allow(bar_vm).to receive(:ui).and_return(Vagrant::UI::Silent.new)
|
||||||
|
allow(bar_vm).to receive(:state).and_return(nil)
|
||||||
|
|
||||||
environment.stub(machine_names: [:foo, :bar])
|
allow(environment).to receive(:machine_names).and_return([:foo, :bar])
|
||||||
allow(environment).to receive(:machine).with(:foo, environment.default_provider).and_return(foo_vm)
|
allow(environment).to receive(:machine).with(:foo, environment.default_provider).and_return(foo_vm)
|
||||||
allow(environment).to receive(:machine).with(:bar, environment.default_provider).and_return(bar_vm)
|
allow(environment).to receive(:machine).with(:bar, environment.default_provider).and_return(bar_vm)
|
||||||
|
|
||||||
|
@ -108,7 +110,7 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an exception if the named VM doesn't exist" do
|
it "raises an exception if the named VM doesn't exist" do
|
||||||
environment.stub(machine_names: [:default])
|
allow(environment).to receive(:machine_names).and_return([:default])
|
||||||
allow(environment).to receive(:machine).with(:foo, anything).and_return(nil)
|
allow(environment).to receive(:machine).with(:foo, anything).and_return(nil)
|
||||||
|
|
||||||
expect { instance.with_target_vms("foo") }.
|
expect { instance.with_target_vms("foo") }.
|
||||||
|
@ -117,9 +119,10 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
|
|
||||||
it "yields the given VM if a name is given" do
|
it "yields the given VM if a name is given" do
|
||||||
foo_vm = double("foo")
|
foo_vm = double("foo")
|
||||||
foo_vm.stub(name: "foo", provider: :foobarbaz)
|
allow(foo_vm).to receive(:name).and_return("foo")
|
||||||
foo_vm.stub(ui: Vagrant::UI::Silent.new)
|
allow(foo_vm).to receive(:provider).and_return(:foobarbaz)
|
||||||
foo_vm.stub(state: nil)
|
allow(foo_vm).to receive(:ui).and_return(Vagrant::UI::Silent.new)
|
||||||
|
allow(foo_vm).to receive(:state).and_return(nil)
|
||||||
|
|
||||||
allow(environment).to receive(:machine).with(:foo, environment.default_provider).and_return(foo_vm)
|
allow(environment).to receive(:machine).with(:foo, environment.default_provider).and_return(foo_vm)
|
||||||
|
|
||||||
|
@ -130,9 +133,10 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
|
|
||||||
it "calls state after yielding the vm to update the machine index" do
|
it "calls state after yielding the vm to update the machine index" do
|
||||||
foo_vm = double("foo")
|
foo_vm = double("foo")
|
||||||
foo_vm.stub(name: "foo", provider: :foobarbaz)
|
allow(foo_vm).to receive(:name).and_return("foo")
|
||||||
foo_vm.stub(ui: Vagrant::UI::Silent.new)
|
allow(foo_vm).to receive(:provider).and_return(:foobarbaz)
|
||||||
foo_vm.stub(state: nil)
|
allow(foo_vm).to receive(:ui).and_return(Vagrant::UI::Silent.new)
|
||||||
|
allow(foo_vm).to receive(:state).and_return(nil)
|
||||||
|
|
||||||
allow(environment).to receive(:machine).with(:foo, environment.default_provider).and_return(foo_vm)
|
allow(environment).to receive(:machine).with(:foo, environment.default_provider).and_return(foo_vm)
|
||||||
|
|
||||||
|
@ -145,9 +149,10 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
foo_vm = double("foo")
|
foo_vm = double("foo")
|
||||||
provider = :foobarbaz
|
provider = :foobarbaz
|
||||||
|
|
||||||
foo_vm.stub(name: "foo", provider: provider)
|
allow(foo_vm).to receive(:name).and_return("foo")
|
||||||
foo_vm.stub(ui: Vagrant::UI::Silent.new)
|
allow(foo_vm).to receive(:provider).and_return(provider)
|
||||||
foo_vm.stub(state: nil)
|
allow(foo_vm).to receive(:ui).and_return(Vagrant::UI::Silent.new)
|
||||||
|
allow(foo_vm).to receive(:state).and_return(nil)
|
||||||
allow(environment).to receive(:machine).with(:foo, provider).and_return(foo_vm)
|
allow(environment).to receive(:machine).with(:foo, provider).and_return(foo_vm)
|
||||||
|
|
||||||
vms = []
|
vms = []
|
||||||
|
@ -158,7 +163,7 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
it "should raise an exception if an active machine exists with a different provider" do
|
it "should raise an exception if an active machine exists with a different provider" do
|
||||||
name = :foo
|
name = :foo
|
||||||
|
|
||||||
environment.stub(active_machines: [[name, :vmware]])
|
allow(environment).to receive(:active_machines).and_return([[name, :vmware]])
|
||||||
expect { instance.with_target_vms(name.to_s, provider: :foo) }.
|
expect { instance.with_target_vms(name.to_s, provider: :foo) }.
|
||||||
to raise_error Vagrant::Errors::ActiveMachineWithDifferentProvider
|
to raise_error Vagrant::Errors::ActiveMachineWithDifferentProvider
|
||||||
end
|
end
|
||||||
|
@ -168,11 +173,12 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
provider = :vmware
|
provider = :vmware
|
||||||
vmware_vm = double("vmware_vm")
|
vmware_vm = double("vmware_vm")
|
||||||
|
|
||||||
environment.stub(active_machines: [[name, provider]])
|
allow(environment).to receive(:active_machines).and_return([[name, provider]])
|
||||||
allow(environment).to receive(:machine).with(name, provider).and_return(vmware_vm)
|
allow(environment).to receive(:machine).with(name, provider).and_return(vmware_vm)
|
||||||
vmware_vm.stub(name: name, provider: provider)
|
allow(vmware_vm).to receive(:name).and_return(name)
|
||||||
vmware_vm.stub(ui: Vagrant::UI::Silent.new)
|
allow(vmware_vm).to receive(:provider).and_return(provider)
|
||||||
vmware_vm.stub(state: nil)
|
allow(vmware_vm).to receive(:ui).and_return(Vagrant::UI::Silent.new)
|
||||||
|
allow(vmware_vm).to receive(:state).and_return(nil)
|
||||||
|
|
||||||
vms = []
|
vms = []
|
||||||
instance.with_target_vms(name.to_s) { |vm| vms << vm }
|
instance.with_target_vms(name.to_s) { |vm| vms << vm }
|
||||||
|
@ -184,10 +190,12 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
provider = :vmware
|
provider = :vmware
|
||||||
vmware_vm = double("vmware_vm")
|
vmware_vm = double("vmware_vm")
|
||||||
|
|
||||||
environment.stub(active_machines: [[name, provider]])
|
allow(environment).to receive(:active_machines).and_return([[name, provider]])
|
||||||
allow(environment).to receive(:machine).with(name, provider).and_return(vmware_vm)
|
allow(environment).to receive(:machine).with(name, provider).and_return(vmware_vm)
|
||||||
vmware_vm.stub(name: name, provider: provider, ui: Vagrant::UI::Silent.new)
|
allow(vmware_vm).to receive(:name).and_return(name)
|
||||||
vmware_vm.stub(state: nil)
|
allow(vmware_vm).to receive(:provider).and_return(provider)
|
||||||
|
allow(vmware_vm).to receive(:ui).and_return(Vagrant::UI::Silent.new)
|
||||||
|
allow(vmware_vm).to receive(:state).and_return(nil)
|
||||||
|
|
||||||
vms = []
|
vms = []
|
||||||
instance.with_target_vms(name.to_s, provider: provider) { |vm| vms << vm }
|
instance.with_target_vms(name.to_s, provider: provider) { |vm| vms << vm }
|
||||||
|
@ -199,9 +207,10 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
machine = double("machine")
|
machine = double("machine")
|
||||||
|
|
||||||
allow(environment).to receive(:machine).with(name, environment.default_provider).and_return(machine)
|
allow(environment).to receive(:machine).with(name, environment.default_provider).and_return(machine)
|
||||||
machine.stub(name: name, provider: environment.default_provider)
|
allow(machine).to receive(:name).and_return(name)
|
||||||
machine.stub(ui: Vagrant::UI::Silent.new)
|
allow(machine).to receive(:provider).and_return(environment.default_provider)
|
||||||
machine.stub(state: nil)
|
allow(machine).to receive(:ui).and_return(Vagrant::UI::Silent.new)
|
||||||
|
allow(machine).to receive(:state).and_return(nil)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
instance.with_target_vms(name.to_s) { |m| results << m }
|
instance.with_target_vms(name.to_s) { |m| results << m }
|
||||||
|
@ -213,13 +222,14 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
provider = :vmware
|
provider = :vmware
|
||||||
vmware_vm = double("vmware_vm")
|
vmware_vm = double("vmware_vm")
|
||||||
|
|
||||||
environment.stub(active_machines: [[name, provider]])
|
allow(environment).to receive(:active_machines).and_return([[name, provider]])
|
||||||
allow(environment).to receive(:machine).with(name, provider).and_return(vmware_vm)
|
allow(environment).to receive(:machine).with(name, provider).and_return(vmware_vm)
|
||||||
environment.stub(machine_names: [])
|
allow(environment).to receive(:machine_names).and_return([])
|
||||||
environment.stub(primary_machine_name: name)
|
allow(environment).to receive(:primary_machine_name).and_return(name)
|
||||||
vmware_vm.stub(name: name, provider: provider)
|
allow(vmware_vm).to receive(:name).and_return(name)
|
||||||
vmware_vm.stub(ui: Vagrant::UI::Silent.new)
|
allow(vmware_vm).to receive(:provider).and_return(provider)
|
||||||
vmware_vm.stub(state: nil)
|
allow(vmware_vm).to receive(:ui).and_return(Vagrant::UI::Silent.new)
|
||||||
|
allow(vmware_vm).to receive(:state).and_return(nil)
|
||||||
|
|
||||||
vms = []
|
vms = []
|
||||||
instance.with_target_vms(nil, single_target: true) { |vm| vms << vm }
|
instance.with_target_vms(nil, single_target: true) { |vm| vms << vm }
|
||||||
|
@ -230,13 +240,14 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
name = :foo
|
name = :foo
|
||||||
machine = double("machine")
|
machine = double("machine")
|
||||||
|
|
||||||
environment.stub(active_machines: [])
|
allow(environment).to receive(:active_machines).and_return([])
|
||||||
allow(environment).to receive(:machine).with(name, environment.default_provider).and_return(machine)
|
allow(environment).to receive(:machine).with(name, environment.default_provider).and_return(machine)
|
||||||
environment.stub(machine_names: [])
|
allow(environment).to receive(:machine_names).and_return([])
|
||||||
environment.stub(primary_machine_name: name)
|
allow(environment).to receive(:primary_machine_name).and_return(name)
|
||||||
machine.stub(name: name, provider: environment.default_provider)
|
allow(machine).to receive(:name).and_return(name)
|
||||||
machine.stub(ui: Vagrant::UI::Silent.new)
|
allow(machine).to receive(:provider).and_return(environment.default_provider)
|
||||||
machine.stub(state: nil)
|
allow(machine).to receive(:ui).and_return(Vagrant::UI::Silent.new)
|
||||||
|
allow(machine).to receive(:state).and_return(nil)
|
||||||
|
|
||||||
vms = []
|
vms = []
|
||||||
instance.with_target_vms(nil, single_target: true) { |vm| vms << machine }
|
instance.with_target_vms(nil, single_target: true) { |vm| vms << machine }
|
||||||
|
@ -255,7 +266,7 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
other_machine.id = "foo"
|
other_machine.id = "foo"
|
||||||
|
|
||||||
# Make sure we don't have a root path, to test
|
# Make sure we don't have a root path, to test
|
||||||
environment.stub(root_path: nil)
|
allow(environment).to receive(:root_path).and_return(nil)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
subject.with_target_vms(other_machine.index_uuid) { |m| results << m }
|
subject.with_target_vms(other_machine.index_uuid) { |m| results << m }
|
||||||
|
@ -282,7 +293,7 @@ describe Vagrant::Plugin::V2::Command do
|
||||||
FileUtils.rm_rf(iso_env.workdir)
|
FileUtils.rm_rf(iso_env.workdir)
|
||||||
|
|
||||||
# Make sure we don't have a root path, to test
|
# Make sure we don't have a root path, to test
|
||||||
environment.stub(root_path: nil)
|
allow(environment).to receive(:root_path).and_return(nil)
|
||||||
|
|
||||||
# Run the command
|
# Run the command
|
||||||
expect {
|
expect {
|
||||||
|
|
|
@ -2,7 +2,8 @@ require File.expand_path("../../../../base", __FILE__)
|
||||||
|
|
||||||
describe Vagrant::Plugin::V2::Plugin do
|
describe Vagrant::Plugin::V2::Plugin do
|
||||||
before do
|
before do
|
||||||
described_class.stub(manager: Vagrant::Plugin::V2::Manager.new)
|
allow(described_class).to receive(:manager)
|
||||||
|
.and_return(Vagrant::Plugin::V2::Manager.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be able to set and get the name" do
|
it "should be able to set and get the name" do
|
||||||
|
@ -71,8 +72,8 @@ describe Vagrant::Plugin::V2::Plugin do
|
||||||
command("bar", primary: false) { "bar" }
|
command("bar", primary: false) { "bar" }
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(plugin.components.commands[:foo][1][:primary]).to be_true
|
expect(plugin.components.commands[:foo][1][:primary]).to be(true)
|
||||||
expect(plugin.components.commands[:bar][1][:primary]).to be_false
|
expect(plugin.components.commands[:bar][1][:primary]).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
["spaces bad", "sym^bols"].each do |bad|
|
["spaces bad", "sym^bols"].each do |bad|
|
||||||
|
|
|
@ -42,14 +42,14 @@ describe Vagrant::Plugin::V2::Provider do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
machine.stub(id: "YEAH")
|
allow(machine).to receive(:id).and_return("YEAH")
|
||||||
|
|
||||||
instance._initialize("foo", machine)
|
instance._initialize("foo", machine)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can execute capabilities" do
|
it "can execute capabilities" do
|
||||||
expect(subject.capability?(:foo)).to be_false
|
expect(subject.capability?(:foo)).to be(false)
|
||||||
expect(subject.capability?(:bar)).to be_true
|
expect(subject.capability?(:bar)).to be(true)
|
||||||
|
|
||||||
expect { subject.capability(:bar) }.
|
expect { subject.capability(:bar) }.
|
||||||
to raise_error("bar YEAH")
|
to raise_error("bar YEAH")
|
||||||
|
|
|
@ -18,25 +18,25 @@ describe Vagrant do
|
||||||
describe "#in_installer?" do
|
describe "#in_installer?" do
|
||||||
it "is not if env is not set" do
|
it "is not if env is not set" do
|
||||||
with_temp_env("VAGRANT_INSTALLER_ENV" => nil) do
|
with_temp_env("VAGRANT_INSTALLER_ENV" => nil) do
|
||||||
expect(subject.in_installer?).to be_false
|
expect(subject.in_installer?).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is if env is set" do
|
it "is if env is set" do
|
||||||
with_temp_env("VAGRANT_INSTALLER_ENV" => "/foo") do
|
with_temp_env("VAGRANT_INSTALLER_ENV" => "/foo") do
|
||||||
expect(subject.in_installer?).to be_true
|
expect(subject.in_installer?).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#installer_embedded_dir" do
|
describe "#installer_embedded_dir" do
|
||||||
it "returns nil if not in an installer" do
|
it "returns nil if not in an installer" do
|
||||||
Vagrant.stub(in_installer?: false)
|
allow(Vagrant).to receive(:in_installer?).and_return(false)
|
||||||
expect(subject.installer_embedded_dir).to be_nil
|
expect(subject.installer_embedded_dir).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the set directory" do
|
it "returns the set directory" do
|
||||||
Vagrant.stub(in_installer?: true)
|
allow(Vagrant).to receive(:in_installer?).and_return(true)
|
||||||
|
|
||||||
with_temp_env("VAGRANT_INSTALLER_EMBEDDED_DIR" => "/foo") do
|
with_temp_env("VAGRANT_INSTALLER_EMBEDDED_DIR" => "/foo") do
|
||||||
expect(subject.installer_embedded_dir).to eq("/foo")
|
expect(subject.installer_embedded_dir).to eq("/foo")
|
||||||
|
@ -47,13 +47,13 @@ describe Vagrant do
|
||||||
describe "#plugins_enabled?" do
|
describe "#plugins_enabled?" do
|
||||||
it "returns true if the env is not set" do
|
it "returns true if the env is not set" do
|
||||||
with_temp_env("VAGRANT_NO_PLUGINS" => nil) do
|
with_temp_env("VAGRANT_NO_PLUGINS" => nil) do
|
||||||
expect(subject.plugins_enabled?).to be_true
|
expect(subject.plugins_enabled?).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if the env is set" do
|
it "returns false if the env is set" do
|
||||||
with_temp_env("VAGRANT_NO_PLUGINS" => "1") do
|
with_temp_env("VAGRANT_NO_PLUGINS" => "1") do
|
||||||
expect(subject.plugins_enabled?).to be_false
|
expect(subject.plugins_enabled?).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe Vagrant::UI::Basic do
|
||||||
it "outputs within the a new thread" do
|
it "outputs within the a new thread" do
|
||||||
current = Thread.current.object_id
|
current = Thread.current.object_id
|
||||||
|
|
||||||
expect(subject).to receive(:safe_puts).with { |*args|
|
expect(subject).to receive(:safe_puts).with(any_args) { |*args|
|
||||||
expect(Thread.current.object_id).to_not eq(current)
|
expect(Thread.current.object_id).to_not eq(current)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ describe Vagrant::UI::Basic do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "outputs using `puts` by default" do
|
it "outputs using `puts` by default" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message, **opts|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, **opts|
|
||||||
expect(opts[:printer]).to eq(:puts)
|
expect(opts[:printer]).to eq(:puts)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ describe Vagrant::UI::Basic do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "outputs using `print` if new_line is false" do
|
it "outputs using `print` if new_line is false" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message, **opts|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, **opts|
|
||||||
expect(opts[:printer]).to eq(:print)
|
expect(opts[:printer]).to eq(:print)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ describe Vagrant::UI::Basic do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "outputs using `print` if new_line is false" do
|
it "outputs using `print` if new_line is false" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message, **opts|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, **opts|
|
||||||
expect(opts[:printer]).to eq(:print)
|
expect(opts[:printer]).to eq(:print)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ describe Vagrant::UI::Basic do
|
||||||
stdout = StringIO.new
|
stdout = StringIO.new
|
||||||
subject.stdout = stdout
|
subject.stdout = stdout
|
||||||
|
|
||||||
expect(subject).to receive(:safe_puts).with { |message, **opts|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, **opts|
|
||||||
expect(opts[:io]).to be(stdout)
|
expect(opts[:io]).to be(stdout)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ describe Vagrant::UI::Basic do
|
||||||
stderr = StringIO.new
|
stderr = StringIO.new
|
||||||
subject.stderr = stderr
|
subject.stderr = stderr
|
||||||
|
|
||||||
expect(subject).to receive(:safe_puts).with { |message, **opts|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, **opts|
|
||||||
expect(opts[:io]).to be(stderr)
|
expect(opts[:io]).to be(stderr)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ describe Vagrant::UI::Basic do
|
||||||
|
|
||||||
context "#detail" do
|
context "#detail" do
|
||||||
it "outputs details" do
|
it "outputs details" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message, **opts|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, **opts|
|
||||||
expect(message).to eq("foo")
|
expect(message).to eq("foo")
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ describe Vagrant::UI::Colored do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not bold by default with a color" do
|
it "does not bold by default with a color" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message, *args|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, *args|
|
||||||
expect(message).to start_with("\033[0;31m")
|
expect(message).to start_with("\033[0;31m")
|
||||||
expect(message).to end_with("\033[0m")
|
expect(message).to end_with("\033[0m")
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ describe Vagrant::UI::Colored do
|
||||||
|
|
||||||
describe "#error" do
|
describe "#error" do
|
||||||
it "colors red" do
|
it "colors red" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message, *args|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, *args|
|
||||||
expect(message).to start_with("\033[0;31m")
|
expect(message).to start_with("\033[0;31m")
|
||||||
expect(message).to end_with("\033[0m")
|
expect(message).to end_with("\033[0m")
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ describe Vagrant::UI::Colored do
|
||||||
it "colors output to color specified in global opts" do
|
it "colors output to color specified in global opts" do
|
||||||
subject.opts[:color] = :red
|
subject.opts[:color] = :red
|
||||||
|
|
||||||
expect(subject).to receive(:safe_puts).with { |message, *args|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, *args|
|
||||||
expect(message).to start_with("\033[0;31m")
|
expect(message).to start_with("\033[0;31m")
|
||||||
expect(message).to end_with("\033[0m")
|
expect(message).to end_with("\033[0m")
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ describe Vagrant::UI::Colored do
|
||||||
it "colors output to specified color over global opts" do
|
it "colors output to specified color over global opts" do
|
||||||
subject.opts[:color] = :red
|
subject.opts[:color] = :red
|
||||||
|
|
||||||
expect(subject).to receive(:safe_puts).with { |message, *args|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, *args|
|
||||||
expect(message).to start_with("\033[0;32m")
|
expect(message).to start_with("\033[0;32m")
|
||||||
expect(message).to end_with("\033[0m")
|
expect(message).to end_with("\033[0m")
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ describe Vagrant::UI::Colored do
|
||||||
it "bolds the output if specified" do
|
it "bolds the output if specified" do
|
||||||
subject.opts[:color] = :red
|
subject.opts[:color] = :red
|
||||||
|
|
||||||
expect(subject).to receive(:safe_puts).with { |message, *args|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, *args|
|
||||||
expect(message).to start_with("\033[1;31m")
|
expect(message).to start_with("\033[1;31m")
|
||||||
expect(message).to end_with("\033[0m")
|
expect(message).to end_with("\033[0m")
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ describe Vagrant::UI::Colored do
|
||||||
|
|
||||||
describe "#success" do
|
describe "#success" do
|
||||||
it "colors green" do
|
it "colors green" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message, *args|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, *args|
|
||||||
expect(message).to start_with("\033[0;32m")
|
expect(message).to start_with("\033[0;32m")
|
||||||
expect(message).to end_with("\033[0m")
|
expect(message).to end_with("\033[0m")
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ describe Vagrant::UI::Colored do
|
||||||
|
|
||||||
describe "#warn" do
|
describe "#warn" do
|
||||||
it "colors yellow" do
|
it "colors yellow" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message, *args|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message, *args|
|
||||||
expect(message).to start_with("\033[0;33m")
|
expect(message).to start_with("\033[0;33m")
|
||||||
expect(message).to end_with("\033[0m")
|
expect(message).to end_with("\033[0m")
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ describe Vagrant::UI::MachineReadable do
|
||||||
[:detail, :warn, :error, :info, :output, :success].each do |method|
|
[:detail, :warn, :error, :info, :output, :success].each do |method|
|
||||||
describe "##{method}" do
|
describe "##{method}" do
|
||||||
it "outputs UI type to the machine-readable output" do
|
it "outputs UI type to the machine-readable output" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message|
|
||||||
parts = message.split(",")
|
parts = message.split(",")
|
||||||
expect(parts.length).to eq(5)
|
expect(parts.length).to eq(5)
|
||||||
expect(parts[1]).to eq("")
|
expect(parts[1]).to eq("")
|
||||||
|
@ -235,7 +235,7 @@ describe Vagrant::UI::MachineReadable do
|
||||||
|
|
||||||
describe "#machine" do
|
describe "#machine" do
|
||||||
it "is formatted properly" do
|
it "is formatted properly" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message|
|
||||||
parts = message.split(",")
|
parts = message.split(",")
|
||||||
expect(parts.length).to eq(5)
|
expect(parts.length).to eq(5)
|
||||||
expect(parts[1]).to eq("")
|
expect(parts[1]).to eq("")
|
||||||
|
@ -249,7 +249,7 @@ describe Vagrant::UI::MachineReadable do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "includes a target if given" do
|
it "includes a target if given" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message|
|
||||||
parts = message.split(",")
|
parts = message.split(",")
|
||||||
expect(parts.length).to eq(4)
|
expect(parts.length).to eq(4)
|
||||||
expect(parts[1]).to eq("boom")
|
expect(parts[1]).to eq("boom")
|
||||||
|
@ -262,7 +262,7 @@ describe Vagrant::UI::MachineReadable do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "replaces commas" do
|
it "replaces commas" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message|
|
||||||
parts = message.split(",")
|
parts = message.split(",")
|
||||||
expect(parts.length).to eq(4)
|
expect(parts.length).to eq(4)
|
||||||
expect(parts[3]).to eq("foo%!(VAGRANT_COMMA)bar")
|
expect(parts[3]).to eq("foo%!(VAGRANT_COMMA)bar")
|
||||||
|
@ -273,7 +273,7 @@ describe Vagrant::UI::MachineReadable do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "replaces newlines" do
|
it "replaces newlines" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message|
|
||||||
parts = message.split(",")
|
parts = message.split(",")
|
||||||
expect(parts.length).to eq(4)
|
expect(parts.length).to eq(4)
|
||||||
expect(parts[3]).to eq("foo\\nbar\\r")
|
expect(parts[3]).to eq("foo\\nbar\\r")
|
||||||
|
@ -286,7 +286,7 @@ describe Vagrant::UI::MachineReadable do
|
||||||
# This is for a bug where JSON parses are frozen and an
|
# This is for a bug where JSON parses are frozen and an
|
||||||
# exception was being raised.
|
# exception was being raised.
|
||||||
it "works properly with frozen string arguments" do
|
it "works properly with frozen string arguments" do
|
||||||
expect(subject).to receive(:safe_puts).with { |message|
|
expect(subject).to receive(:safe_puts).with(any_args) { |message|
|
||||||
parts = message.split(",")
|
parts = message.split(",")
|
||||||
expect(parts.length).to eq(4)
|
expect(parts.length).to eq(4)
|
||||||
expect(parts[3]).to eq("foo\\nbar\\r")
|
expect(parts[3]).to eq("foo\\nbar\\r")
|
||||||
|
@ -350,7 +350,7 @@ describe Vagrant::UI::Prefixed do
|
||||||
|
|
||||||
describe "#opts" do
|
describe "#opts" do
|
||||||
it "is the parent's opts" do
|
it "is the parent's opts" do
|
||||||
ui.stub(opts: Object.new)
|
allow(ui).to receive(:opts).and_return(Object.new)
|
||||||
expect(subject.opts).to be(ui.opts)
|
expect(subject.opts).to be(ui.opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,8 +9,8 @@ describe Vagrant::Util::Downloader do
|
||||||
|
|
||||||
let(:subprocess_result) do
|
let(:subprocess_result) do
|
||||||
double("subprocess_result").tap do |result|
|
double("subprocess_result").tap do |result|
|
||||||
result.stub(exit_code: exit_code)
|
allow(result).to receive(:exit_code).and_return(exit_code)
|
||||||
result.stub(stderr: "")
|
allow(result).to receive(:stderr).and_return("")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ describe Vagrant::Util::Downloader do
|
||||||
with("curl", *curl_options).
|
with("curl", *curl_options).
|
||||||
and_return(subprocess_result)
|
and_return(subprocess_result)
|
||||||
|
|
||||||
expect(subject.download!).to be_true
|
expect(subject.download!).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ describe Vagrant::Util::Downloader do
|
||||||
with("curl", *curl_options).
|
with("curl", *curl_options).
|
||||||
and_return(subprocess_result)
|
and_return(subprocess_result)
|
||||||
|
|
||||||
expect(subject.download!).to be_true
|
expect(subject.download!).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ describe Vagrant::Util::Downloader do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not raise an exception" do
|
it "should not raise an exception" do
|
||||||
expect(subject.download!).to be_true
|
expect(subject.download!).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ describe Vagrant::Util::Downloader do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not raise an exception" do
|
it "should not raise an exception" do
|
||||||
expect(subject.download!).to be_true
|
expect(subject.download!).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ describe Vagrant::Util::Downloader do
|
||||||
}
|
}
|
||||||
|
|
||||||
it "returns the output" do
|
it "returns the output" do
|
||||||
subprocess_result.stub(stdout: "foo")
|
allow(subprocess_result).to receive(:stdout).and_return("foo")
|
||||||
|
|
||||||
options = curl_options.dup
|
options = curl_options.dup
|
||||||
options.unshift("-I")
|
options.unshift("-I")
|
||||||
|
|
|
@ -52,14 +52,14 @@ describe Vagrant::Util::Subprocess do
|
||||||
context "when subprocess has not been started" do
|
context "when subprocess has not been started" do
|
||||||
it "should return false" do
|
it "should return false" do
|
||||||
sp = described_class.new("ls")
|
sp = described_class.new("ls")
|
||||||
expect(sp.running?).to be_false
|
expect(sp.running?).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context "when subprocess has completed" do
|
context "when subprocess has completed" do
|
||||||
it "should return false" do
|
it "should return false" do
|
||||||
sp = described_class.new("ls")
|
sp = described_class.new("ls")
|
||||||
sp.execute
|
sp.execute
|
||||||
expect(sp.running?).to be_false
|
expect(sp.running?).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context "when subprocess is running" do
|
context "when subprocess is running" do
|
||||||
|
@ -67,7 +67,7 @@ describe Vagrant::Util::Subprocess do
|
||||||
sp = described_class.new("sleep", "5")
|
sp = described_class.new("sleep", "5")
|
||||||
thread = Thread.new{ sp.execute }
|
thread = Thread.new{ sp.execute }
|
||||||
sleep(0.3)
|
sleep(0.3)
|
||||||
expect(sp.running?).to be_true
|
expect(sp.running?).to be(true)
|
||||||
sp.stop
|
sp.stop
|
||||||
thread.join
|
thread.join
|
||||||
end
|
end
|
||||||
|
@ -78,7 +78,7 @@ describe Vagrant::Util::Subprocess do
|
||||||
context "when subprocess has not been started" do
|
context "when subprocess has not been started" do
|
||||||
it "should return false" do
|
it "should return false" do
|
||||||
sp = described_class.new("ls")
|
sp = described_class.new("ls")
|
||||||
expect(sp.stop).to be_false
|
expect(sp.stop).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ describe Vagrant::Util::Subprocess do
|
||||||
it "should return false" do
|
it "should return false" do
|
||||||
sp = described_class.new("ls")
|
sp = described_class.new("ls")
|
||||||
sp.execute
|
sp.execute
|
||||||
expect(sp.stop).to be_false
|
expect(sp.stop).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ describe Vagrant::Util::Subprocess do
|
||||||
it "should return true" do
|
it "should return true" do
|
||||||
thread = Thread.new{ sp.execute }
|
thread = Thread.new{ sp.execute }
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
expect(sp.stop).to be_true
|
expect(sp.stop).to be(true)
|
||||||
thread.join
|
thread.join
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ describe Vagrant::Util::Subprocess do
|
||||||
thread = Thread.new{ sp.execute }
|
thread = Thread.new{ sp.execute }
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
sp.stop
|
sp.stop
|
||||||
expect(sp.running?).to be_false
|
expect(sp.running?).to be(false)
|
||||||
thread.join
|
thread.join
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -59,31 +59,31 @@ describe Vagrant do
|
||||||
name "i_am_installed"
|
name "i_am_installed"
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(described_class.has_plugin?("i_am_installed")).to be_true
|
expect(described_class.has_plugin?("i_am_installed")).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return false if the plugin is not installed" do
|
it "should return false if the plugin is not installed" do
|
||||||
expect(described_class.has_plugin?("i_dont_exist")).to be_false
|
expect(described_class.has_plugin?("i_dont_exist")).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "finds plugins by gem name" do
|
it "finds plugins by gem name" do
|
||||||
specs = [Gem::Specification.new]
|
specs = [Gem::Specification.new]
|
||||||
specs[0].name = "foo"
|
specs[0].name = "foo"
|
||||||
Vagrant::Plugin::Manager.instance.stub(installed_specs: specs)
|
allow(Vagrant::Plugin::Manager.instance).to receive(:installed_specs).and_return(specs)
|
||||||
|
|
||||||
expect(described_class.has_plugin?("foo")).to be_true
|
expect(described_class.has_plugin?("foo")).to be(true)
|
||||||
expect(described_class.has_plugin?("bar")).to be_false
|
expect(described_class.has_plugin?("bar")).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "finds plugins by gem name and version" do
|
it "finds plugins by gem name and version" do
|
||||||
specs = [Gem::Specification.new]
|
specs = [Gem::Specification.new]
|
||||||
specs[0].name = "foo"
|
specs[0].name = "foo"
|
||||||
specs[0].version = "1.2.3"
|
specs[0].version = "1.2.3"
|
||||||
Vagrant::Plugin::Manager.instance.stub(installed_specs: specs)
|
allow(Vagrant::Plugin::Manager.instance).to receive(:installed_specs).and_return(specs)
|
||||||
|
|
||||||
expect(described_class.has_plugin?("foo", "~> 1.2.0")).to be_true
|
expect(described_class.has_plugin?("foo", "~> 1.2.0")).to be(true)
|
||||||
expect(described_class.has_plugin?("foo", "~> 1.0.0")).to be_false
|
expect(described_class.has_plugin?("foo", "~> 1.0.0")).to be(false)
|
||||||
expect(described_class.has_plugin?("bar", "~> 1.2.0")).to be_false
|
expect(described_class.has_plugin?("bar", "~> 1.2.0")).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue