Update rspec to recent version and fix deprecations

This commit is contained in:
Chris Roberts 2017-04-06 14:57:46 -07:00
parent a8103bb84d
commit e8e248d95d
57 changed files with 332 additions and 334 deletions

11
Gemfile
View File

@ -2,8 +2,9 @@ source "https://rubygems.org"
gemspec gemspec
if File.exist?(File.expand_path("../../vagrant-spec", __FILE__)) # Disable until vagrant-spec rspec is pulled up
gem 'vagrant-spec', path: "../vagrant-spec" # if File.exist?(File.expand_path("../../vagrant-spec", __FILE__))
else # gem 'vagrant-spec', path: "../vagrant-spec"
gem 'vagrant-spec', git: "https://github.com/mitchellh/vagrant-spec.git" # else
end # gem 'vagrant-spec', git: "https://github.com/mitchellh/vagrant-spec.git"
# end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -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
} }

View File

@ -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")

View File

@ -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")
} }

View File

@ -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")
} }

View File

@ -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

View File

@ -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.")
} }

View File

@ -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
@ -232,7 +232,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
@ -242,7 +242,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
@ -535,14 +535,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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -515,7 +515,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
@ -525,7 +525,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

View File

@ -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 }

View File

@ -75,12 +75,12 @@ describe VagrantPlugins::DockerProvider::Driver do
context 'when container exists' do context 'when container exists' do
before { subject.stub(execute: "foo\n#{cid}\nbar") } before { subject.stub(execute: "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 { subject.stub(execute: "foo\n#{cid}extra\nbar") }
it { expect(result).to be_false } it { expect(result).to be_falsey }
end end
end end
@ -102,12 +102,12 @@ describe VagrantPlugins::DockerProvider::Driver do
context 'when container exists' do context 'when container exists' do
before { subject.stub(execute: "foo\n#{cid}\nbar") } before { subject.stub(execute: "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 { subject.stub(execute: "foo\n#{cid}extra\nbar") }
it { expect(result).to be_false } it { expect(result).to be_falsey }
end end
end end

View File

@ -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({

View File

@ -42,8 +42,6 @@ describe VagrantPlugins::ProviderVirtualBox::SyncedFolder do
machine.stub(driver: driver) machine.stub(driver: driver)
end end
it "should share the folders" do it "should share the folders"
pending
end
end end
end end

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -44,6 +44,7 @@ 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)) }
@ -73,7 +74,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")
@ -83,11 +84,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)/ }
@ -101,11 +102,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
@ -118,30 +119,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)
@ -150,25 +151,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")
@ -176,22 +177,22 @@ 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, "", "")) Vagrant::Util::Subprocess.stub(execute: Vagrant::Util::Subprocess::Result.new(0, "", ""))
@ -200,7 +201,7 @@ VF
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
@ -258,18 +259,18 @@ 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*$/)
# Ending this block with a negative expectation (to_not / not_to) # Ending this block with a negative expectation (to_not / not_to)
# would lead to a failure of the above expectation. # would lead to a failure of the above expectation.
true true
} }.and_return(default_execute_result)
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
@ -281,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
@ -294,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
@ -346,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
@ -371,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
@ -384,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
@ -395,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
@ -420,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
@ -449,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
@ -491,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
@ -523,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
@ -538,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
@ -556,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
@ -576,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
@ -590,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
@ -606,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
@ -620,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
@ -635,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
@ -649,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
@ -669,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("-i '/an/other/identity'") expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-i '/an/other/identity'")
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-i '/yet/an/other/key'") expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-i '/yet/an/other/key'")
} }.and_return(default_execute_result)
end end
end end
@ -686,10 +687,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
@ -699,10 +700,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
@ -718,7 +719,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
@ -733,7 +734,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
@ -749,7 +750,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
@ -763,7 +764,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
@ -777,11 +778,11 @@ VF
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
@ -820,11 +821,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
@ -891,17 +892,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 -i '/my/key1' -i '/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 -i '/my/key1' -i '/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
@ -932,10 +933,10 @@ VF
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
@ -950,7 +951,7 @@ VF
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
@ -962,28 +963,28 @@ VF
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")
# Ending this block with a negative expectation (to_not / not_to) # Ending this block with a negative expectation (to_not / not_to)
# would lead to a failure of the above expectation. # would lead to a failure of the above expectation.
true true
} }.and_return(default_execute_result)
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')
# Ending this block with a negative expectation (to_not / not_to) # Ending this block with a negative expectation (to_not / not_to)
# would lead to a failure of the above expectation. # would lead to a failure of the above expectation.
true true
} }.and_return(Vagrant::Util::Subprocess::Result.new(0, "", ""))
end end
end end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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) Vagrant::Util::Subprocess.stub(:execute){ result }
guest.stub(capability?: false) guest.stub(:capability?){ false }
end end
it "doesn't raise an error if it succeeds" do it "doesn't raise an error if it succeeds" do
@ -83,9 +83,9 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
Vagrant::Util::Platform.stub(windows?: true) Vagrant::Util::Platform.stub(windows?: 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
@ -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) Vagrant::Util::Subprocess.stub(:execute){ result }
guest.stub(capability?: false) guest.stub(: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

View File

@ -26,12 +26,12 @@ describe VagrantPlugins::SyncedFolderRSync::SyncedFolder do
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

View File

@ -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")
@ -268,7 +268,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
env[:box_provider] = "virtualbox" env[:box_provider] = "virtualbox"
box_collection.stub(find: box) box_collection.stub(find: 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")
@ -290,7 +290,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")
@ -338,7 +338,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))
@ -383,7 +383,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))
@ -428,7 +428,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))
@ -479,7 +479,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))
@ -540,7 +540,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))
@ -585,7 +585,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))
@ -729,7 +729,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")
@ -773,7 +773,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")
@ -822,7 +822,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")
@ -862,7 +862,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")
@ -907,7 +907,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")
@ -955,7 +955,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")
@ -1003,7 +1003,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")
@ -1179,11 +1179,11 @@ 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) box_collection.stub(find: 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)

View File

@ -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

View File

@ -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

View File

@ -54,7 +54,7 @@ describe Vagrant::Action::Builtin::HandleBox do
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])
@ -93,7 +93,7 @@ describe Vagrant::Action::Builtin::HandleBox do
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)
@ -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)

View File

@ -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

View File

@ -23,7 +23,7 @@ describe Vagrant::Action::Builtin::IsState 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
it "sets result to true if is proper state" do it "sets result to true if is proper state" do
@ -34,7 +34,7 @@ describe Vagrant::Action::Builtin::IsState 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 "inverts the result if specified" do it "inverts the result if specified" do
@ -45,7 +45,7 @@ describe Vagrant::Action::Builtin::IsState 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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
@ -202,7 +202,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 +216,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 +231,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 +270,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 +282,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 +641,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| klass.should_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
@ -940,7 +940,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
@ -1204,7 +1204,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
@ -1212,7 +1212,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)
} }
@ -1234,7 +1234,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)
} }
@ -1242,7 +1242,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)
} }

View File

@ -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

View File

@ -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
@ -322,7 +322,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)
@ -337,7 +337,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
@ -727,18 +727,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

View File

@ -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)
@ -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
@ -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_false expect(plugins["foo"]["system"]).to be_falsey
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

View File

@ -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

View File

@ -71,8 +71,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|

View File

@ -48,8 +48,8 @@ describe Vagrant::Plugin::V2::Provider do
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")

View File

@ -18,13 +18,13 @@ 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
@ -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

View File

@ -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")

View File

@ -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

View File

@ -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.1) sleep(0.1)
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

View File

@ -59,11 +59,11 @@ 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
@ -71,8 +71,8 @@ describe Vagrant do
specs[0].name = "foo" specs[0].name = "foo"
Vagrant::Plugin::Manager.instance.stub(installed_specs: specs) Vagrant::Plugin::Manager.instance.stub(installed_specs: 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
@ -81,9 +81,9 @@ describe Vagrant do
specs[0].version = "1.2.3" specs[0].version = "1.2.3"
Vagrant::Plugin::Manager.instance.stub(installed_specs: specs) Vagrant::Plugin::Manager.instance.stub(installed_specs: 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

View File

@ -43,8 +43,9 @@ Gem::Specification.new do |s|
# Constraint rake to properly handle deprecated method usage # Constraint rake to properly handle deprecated method usage
# from within rspec # from within rspec
s.add_development_dependency "rake", "~> 11.3.0" s.add_development_dependency "rake", "~> 12.0.0"
s.add_development_dependency "rspec", "~> 2.14.0" s.add_development_dependency "rspec", "~> 3.5.0"
s.add_development_dependency "rspec-its", "~> 1.2.0"
s.add_development_dependency "webmock", "~> 1.20" s.add_development_dependency "webmock", "~> 1.20"
s.add_development_dependency "fake_ftp", "~> 0.1" s.add_development_dependency "fake_ftp", "~> 0.1"