Convert specs to RSpec 2.14.8 syntax with Transpec

This conversion is done by Transpec 1.10.2 with the following command:
    transpec test/unit/

* 507 conversions
    from: obj.should
      to: expect(obj).to

* 394 conversions
    from: == expected
      to: eq(expected)

* 260 conversions
    from: obj.should_receive(:message)
      to: expect(obj).to receive(:message)

* 85 conversions
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

* 25 conversions
    from: its(:attr) { }
      to: describe '#attr' do subject { super().attr }; it { } end

* 19 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 7 conversions
    from: obj.should_not_receive(:message)
      to: expect(obj).not_to receive(:message)

* 3 conversions
    from: Klass.any_instance.should_receive(:message)
      to: expect_any_instance_of(Klass).to receive(:message)
This commit is contained in:
Fabio Rehm 2014-03-14 12:02:07 -03:00
parent f0ee138e87
commit 54656151cf
100 changed files with 1186 additions and 1091 deletions

View File

@ -32,11 +32,11 @@ 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
action_runner.should_receive(:run).with do |action, **opts| expect(action_runner).to receive(:run).with { |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
end }
subject.execute subject.execute
end end
@ -46,11 +46,11 @@ 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
action_runner.should_receive(:run).with do |action, **opts| expect(action_runner).to receive(:run).with { |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
end }
subject.execute subject.execute
end end

View File

@ -32,10 +32,10 @@ describe VagrantPlugins::CommandBox::Command::Remove do
let(:argv) { ["foo"] } let(:argv) { ["foo"] }
it "invokes the action runner" do it "invokes the action runner" do
action_runner.should_receive(:run).with do |action, opts| expect(action_runner).to receive(:run).with { |action, opts|
expect(opts[:box_name]).to eq("foo") expect(opts[:box_name]).to eq("foo")
true true
end }
subject.execute subject.execute
end end
@ -45,11 +45,11 @@ 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
action_runner.should_receive(:run).with do |action, opts| expect(action_runner).to receive(:run).with { |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
end }
subject.execute subject.execute
end end

View File

@ -42,7 +42,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
it "doesn't update if they're up to date" do it "doesn't update if they're up to date" do
called = false called = false
action_runner.stub(:run) do |callable, opts| allow(action_runner).to receive(:run) do |callable, opts|
if opts[:box_provider] if opts[:box_provider]
called = true called = true
end end
@ -79,7 +79,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
end end
action_called = false action_called = false
action_runner.stub(:run) do |action, opts| allow(action_runner).to receive(:run) do |action, opts|
if opts[:box_provider] if opts[:box_provider]
action_called = true action_called = true
expect(opts[:box_url]).to eq(metadata_url.to_s) expect(opts[:box_url]).to eq(metadata_url.to_s)
@ -98,7 +98,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
it "raises an error if there are multiple providers" do it "raises an error if there are multiple providers" do
test_iso_env.box3("foo", "1.0", :vmware) test_iso_env.box3("foo", "1.0", :vmware)
action_runner.should_receive(:run).never expect(action_runner).to receive(:run).never
expect { subject.execute }. expect { subject.execute }.
to raise_error(Vagrant::Errors::BoxUpdateMultiProvider) to raise_error(Vagrant::Errors::BoxUpdateMultiProvider)
@ -133,7 +133,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
test_iso_env.box3("foo", "1.0", :vmware) test_iso_env.box3("foo", "1.0", :vmware)
action_called = false action_called = false
action_runner.stub(:run) do |action, opts| allow(action_runner).to receive(:run) do |action, opts|
if opts[:box_provider] if opts[:box_provider]
action_called = true action_called = true
expect(opts[:box_url]).to eq(metadata_url.to_s) expect(opts[:box_url]).to eq(metadata_url.to_s)
@ -150,7 +150,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
end end
it "raises an error if that provider doesn't exist" do it "raises an error if that provider doesn't exist" do
action_runner.should_receive(:run).never expect(action_runner).to receive(:run).never
expect { subject.execute }. expect { subject.execute }.
to raise_error(Vagrant::Errors::BoxNotFoundWithProvider) to raise_error(Vagrant::Errors::BoxNotFoundWithProvider)
@ -161,7 +161,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
let(:argv) { ["--box", "nope"] } let(:argv) { ["--box", "nope"] }
it "raises an exception" do it "raises an exception" do
action_runner.should_receive(:run).never expect(action_runner).to receive(:run).never
expect { subject.execute }. expect { subject.execute }.
to raise_error(Vagrant::Errors::BoxNotFound) to raise_error(Vagrant::Errors::BoxNotFound)
@ -171,7 +171,7 @@ describe VagrantPlugins::CommandBox::Command::Update do
context "updating environment machines" do context "updating environment machines" do
before do before do
subject.stub(:with_target_vms) { |&block| block.call machine } allow(subject).to receive(:with_target_vms) { |&block| block.call machine }
end end
let(:box) do let(:box) do
@ -183,18 +183,18 @@ describe VagrantPlugins::CommandBox::Command::Update do
end end
it "ignores machines without boxes" do it "ignores machines without boxes" do
action_runner.should_receive(:run).never expect(action_runner).to receive(:run).never
subject.execute subject.execute
end end
it "doesn't update boxes if they're up-to-date" do it "doesn't update boxes if they're up-to-date" do
machine.stub(box: box) machine.stub(box: box)
box.should_receive(:has_update?). expect(box).to receive(:has_update?).
with(machine.config.vm.box_version). with(machine.config.vm.box_version).
and_return(nil) and_return(nil)
action_runner.should_receive(:run).never expect(action_runner).to receive(:run).never
subject.execute subject.execute
end end
@ -221,17 +221,17 @@ describe VagrantPlugins::CommandBox::Command::Update do
RAW RAW
machine.stub(box: box) machine.stub(box: box)
box.should_receive(:has_update?). expect(box).to receive(:has_update?).
with(machine.config.vm.box_version). with(machine.config.vm.box_version).
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")])
action_runner.should_receive(:run).with do |action, opts| expect(action_runner).to receive(:run).with { |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")
expect(opts[:ui]).to equal(machine.ui) expect(opts[:ui]).to equal(machine.ui)
true true
end }
subject.execute subject.execute
end end

View File

@ -28,11 +28,11 @@ 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 }]
iso_env.ui.should_receive(:info).with do |message, opts| expect(iso_env.ui).to receive(:info).with { |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")
end }
subject.execute subject.execute
end end

View File

@ -17,10 +17,10 @@ describe VagrantPlugins::CommandPlugin::Action::InstallGem do
describe "#call" do describe "#call" do
it "should install the plugin" do it "should install the plugin" do
spec = Gem::Specification.new spec = Gem::Specification.new
manager.should_receive(:install_plugin).with( expect(manager).to receive(:install_plugin).with(
"foo", version: nil, require: nil, sources: nil, verbose: false).once.and_return(spec) "foo", version: nil, require: nil, sources: nil, verbose: false).once.and_return(spec)
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
env[:plugin_name] = "foo" env[:plugin_name] = "foo"
subject.call(env) subject.call(env)
@ -28,10 +28,10 @@ describe VagrantPlugins::CommandPlugin::Action::InstallGem do
it "should specify the version if given" do it "should specify the version if given" do
spec = Gem::Specification.new spec = Gem::Specification.new
manager.should_receive(:install_plugin).with( expect(manager).to receive(:install_plugin).with(
"foo", version: "bar", require: nil, sources: nil, verbose: false).once.and_return(spec) "foo", version: "bar", require: nil, sources: nil, verbose: false).once.and_return(spec)
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
env[:plugin_name] = "foo" env[:plugin_name] = "foo"
env[:plugin_version] = "bar" env[:plugin_version] = "bar"
@ -40,10 +40,10 @@ describe VagrantPlugins::CommandPlugin::Action::InstallGem do
it "should specify the entrypoint if given" do it "should specify the entrypoint if given" do
spec = Gem::Specification.new spec = Gem::Specification.new
manager.should_receive(:install_plugin).with( expect(manager).to receive(:install_plugin).with(
"foo", version: "bar", require: "baz", sources: nil, verbose: false).once.and_return(spec) "foo", version: "bar", require: "baz", sources: nil, verbose: false).once.and_return(spec)
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
env[:plugin_entry_point] = "baz" env[:plugin_entry_point] = "baz"
env[:plugin_name] = "foo" env[:plugin_name] = "foo"
@ -53,10 +53,10 @@ describe VagrantPlugins::CommandPlugin::Action::InstallGem do
it "should specify the sources if given" do it "should specify the sources if given" do
spec = Gem::Specification.new spec = Gem::Specification.new
manager.should_receive(:install_plugin).with( expect(manager).to receive(:install_plugin).with(
"foo", version: nil, require: nil, sources: ["foo"], verbose: false).once.and_return(spec) "foo", version: nil, require: nil, sources: ["foo"], verbose: false).once.and_return(spec)
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
env[:plugin_name] = "foo" env[:plugin_name] = "foo"
env[:plugin_sources] = ["foo"] env[:plugin_sources] = ["foo"]
@ -84,9 +84,9 @@ describe VagrantPlugins::CommandPlugin::Action::InstallGem do
end end
it "should uninstall the plugin" do it "should uninstall the plugin" do
action_runner.should_receive(:run).with do |action, newenv| expect(action_runner).to receive(:run).with { |action, newenv|
expect(newenv[:plugin_name]).to eql("foo") expect(newenv[:plugin_name]).to eql("foo")
end }
subject.recover(env) subject.recover(env)
end end

View File

@ -14,7 +14,7 @@ describe VagrantPlugins::CommandPlugin::Action::PluginExistsCheck do
it "should raise an exception if the plugin doesn't exist" do it "should raise an exception if the plugin doesn't exist" do
manager.stub(installed_plugins: { "foo" => {} }) manager.stub(installed_plugins: { "foo" => {} })
app.should_not_receive(:call) expect(app).not_to receive(:call)
env[:plugin_name] = "bar" env[:plugin_name] = "bar"
expect { subject.call(env) }. expect { subject.call(env) }.
@ -23,7 +23,7 @@ describe VagrantPlugins::CommandPlugin::Action::PluginExistsCheck do
it "should call the app if the plugin is installed" do it "should call the app if the plugin is installed" do
manager.stub(installed_plugins: { "bar" => {} }) manager.stub(installed_plugins: { "bar" => {} })
app.should_receive(:call).once.with(env) expect(app).to receive(:call).once.with(env)
env[:plugin_name] = "bar" env[:plugin_name] = "bar"
subject.call(env) subject.call(env)

View File

@ -15,8 +15,8 @@ describe VagrantPlugins::CommandPlugin::Action::UninstallPlugin do
end end
it "uninstalls the specified plugin" do it "uninstalls the specified plugin" do
manager.should_receive(:uninstall_plugin).with("bar").ordered expect(manager).to receive(:uninstall_plugin).with("bar").ordered
app.should_receive(:call).ordered expect(app).to receive(:call).ordered
env[:plugin_name] = "bar" env[:plugin_name] = "bar"
subject.call(env) subject.call(env)

View File

@ -17,14 +17,14 @@ describe VagrantPlugins::CommandPlugin::Action::UpdateGems do
describe "#call" do describe "#call" do
it "should update all plugins if none are specified" do it "should update all plugins if none are specified" do
manager.should_receive(:update_plugins).with([]).once.and_return([]) expect(manager).to receive(:update_plugins).with([]).once.and_return([])
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
subject.call(env) subject.call(env)
end end
it "should update specified plugins" do it "should update specified plugins" do
manager.should_receive(:update_plugins).with(["foo"]).once.and_return([]) expect(manager).to receive(:update_plugins).with(["foo"]).once.and_return([])
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
env[:plugin_name] = ["foo"] env[:plugin_name] = ["foo"]
subject.call(env) subject.call(env)

View File

@ -31,12 +31,12 @@ describe VagrantPlugins::CommandSSHConfig::Command do
before do before do
machine.stub(ssh_info: ssh_info) machine.stub(ssh_info: ssh_info)
subject.stub(:with_target_vms) { |&block| block.call machine } allow(subject).to receive(:with_target_vms) { |&block| block.call machine }
end end
describe "execute" do describe "execute" do
it "prints out the ssh config for the given machine" do it "prints out the ssh config for the given machine" do
subject.should_receive(:safe_puts).with(<<-SSHCONFIG) expect(subject).to receive(:safe_puts).with(<<-SSHCONFIG)
Host #{machine.name} Host #{machine.name}
HostName testhost.vagrant.dev HostName testhost.vagrant.dev
User testuser User testuser
@ -51,34 +51,34 @@ Host #{machine.name}
end end
it "turns on agent forwarding when it is configured" do it "turns on agent forwarding when it is configured" do
machine.stub(:ssh_info) { ssh_info.merge(:forward_agent => true) } allow(machine).to receive(:ssh_info) { ssh_info.merge(:forward_agent => true) }
subject.should_receive(:safe_puts).with { |ssh_config| expect(subject).to receive(:safe_puts).with { |ssh_config|
ssh_config.should include("ForwardAgent yes") expect(ssh_config).to include("ForwardAgent yes")
} }
subject.execute subject.execute
end end
it "turns on x11 forwarding when it is configured" do it "turns on x11 forwarding when it is configured" do
machine.stub(:ssh_info) { ssh_info.merge(:forward_x11 => true) } allow(machine).to receive(:ssh_info) { ssh_info.merge(:forward_x11 => true) }
subject.should_receive(:safe_puts).with { |ssh_config| expect(subject).to receive(:safe_puts).with { |ssh_config|
ssh_config.should include("ForwardX11 yes") expect(ssh_config).to include("ForwardX11 yes")
} }
subject.execute subject.execute
end end
it "handles multiple private key paths" do it "handles multiple private key paths" do
machine.stub(:ssh_info) { ssh_info.merge(:private_key_path => ["foo", "bar"]) } allow(machine).to receive(:ssh_info) { ssh_info.merge(:private_key_path => ["foo", "bar"]) }
subject.should_receive(:safe_puts).with { |ssh_config| expect(subject).to receive(:safe_puts).with { |ssh_config|
ssh_config.should include("IdentityFile foo") expect(ssh_config).to include("IdentityFile foo")
ssh_config.should include("IdentityFile bar") expect(ssh_config).to include("IdentityFile bar")
} }
subject.execute subject.execute
end end
it "puts quotes around an identityfile path if it has a space" do it "puts quotes around an identityfile path if it has a space" do
machine.stub(:ssh_info) { ssh_info.merge(:private_key_path => ["with a space"]) } allow(machine).to receive(:ssh_info) { ssh_info.merge(:private_key_path => ["with a space"]) }
subject.should_receive(:safe_puts).with { |ssh_config| expect(subject).to receive(:safe_puts).with { |ssh_config|
ssh_config.should include('IdentityFile "with a space"') expect(ssh_config).to include('IdentityFile "with a space"')
} }
subject.execute subject.execute
end end

View File

@ -10,7 +10,7 @@ describe "VagrantPlugins::GuestDebian::Cap::ChangeHostName" do
let(:old_hostname) { 'oldhostname.olddomain.tld' } let(:old_hostname) { 'oldhostname.olddomain.tld' }
before do before do
machine.stub(:communicate).and_return(communicator) allow(machine).to receive(:communicate).and_return(communicator)
communicator.stub_command('hostname -f', stdout: old_hostname) communicator.stub_command('hostname -f', stdout: old_hostname)
end end

View File

@ -9,7 +9,7 @@ describe "VagrantPlugins::GuestRedHat::Cap::ChangeHostName" do
let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) } let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
before do before do
machine.stub(:communicate).and_return(communicator) allow(machine).to receive(:communicate).and_return(communicator)
communicator.stub_command('hostname -f', stdout: old_hostname) communicator.stub_command('hostname -f', stdout: old_hostname)
communicator.expect_command('hostname -f') communicator.expect_command('hostname -f')
end end
@ -61,7 +61,7 @@ describe "VagrantPlugins::GuestRedHat::Cap::ChangeHostName" do
it "does more even when the provided hostname is not different" do it "does more even when the provided hostname is not different" do
described_class.change_host_name(machine, old_hostname) described_class.change_host_name(machine, old_hostname)
communicator.received_commands.to_set.should_not == communicator.expected_commands.keys.to_set expect(communicator.received_commands.to_set).not_to eq(communicator.expected_commands.keys.to_set)
end end
end end
end end

View File

@ -11,7 +11,7 @@ shared_examples "a debian-like host name change" do
it "does nothing when the provided hostname is not different" do it "does nothing when the provided hostname is not different" do
described_class.change_host_name(machine, 'oldhostname.olddomain.tld') described_class.change_host_name(machine, 'oldhostname.olddomain.tld')
communicator.received_commands.should == ['hostname -f'] expect(communicator.received_commands).to eq(['hostname -f'])
end end
describe "flipping out the old hostname in /etc/hosts" do describe "flipping out the old hostname in /etc/hosts" do
@ -36,7 +36,7 @@ shared_examples "a debian-like host name change" do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 localhost 127.0.0.1 localhost
127.0.1.1 newhostname.newdomain.tld newhostname 127.0.1.1 newhostname.newdomain.tld newhostname
RESULT RESULT
@ -56,7 +56,7 @@ shared_examples "a debian-like host name change" do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 localhost 127.0.0.1 localhost
127.0.1.1 newhostname.newdomain.tld newhostname 127.0.1.1 newhostname.newdomain.tld newhostname
@ -79,7 +79,7 @@ shared_examples "a debian-like host name change" do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 localhost 127.0.0.1 localhost
127.0.1.1 newhostname.newdomain.tld newhostname 127.0.1.1 newhostname.newdomain.tld newhostname
RESULT RESULT

View File

@ -51,12 +51,12 @@ shared_examples 'a full redhat-like host name change' do
it "does nothing when the provided hostname is not different" do it "does nothing when the provided hostname is not different" do
described_class.change_host_name(machine, old_hostname) described_class.change_host_name(machine, old_hostname)
communicator.received_commands.to_set.should == communicator.expected_commands.keys.to_set expect(communicator.received_commands.to_set).to eq(communicator.expected_commands.keys.to_set)
end end
it "does more when the provided hostname is a similar version" do it "does more when the provided hostname is a similar version" do
described_class.change_host_name(machine, similar_hostname) described_class.change_host_name(machine, similar_hostname)
communicator.received_commands.to_set.should_not == communicator.expected_commands.keys.to_set expect(communicator.received_commands.to_set).not_to eq(communicator.expected_commands.keys.to_set)
end end
end end
@ -89,7 +89,7 @@ shared_examples 'inserting hostname in /etc/hosts' do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 newhostname.newdomain.tld newhostname localhost.localdomain localhost 127.0.0.1 newhostname.newdomain.tld newhostname localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 ::1 localhost6.localdomain6 localhost6
RESULT RESULT
@ -107,7 +107,7 @@ shared_examples 'inserting hostname in /etc/hosts' do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 newhostname localhost.localdomain localhost 127.0.0.1 newhostname localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 ::1 localhost6.localdomain6 localhost6
RESULT RESULT
@ -129,7 +129,7 @@ shared_examples 'swapping simple hostname in /etc/hosts' do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 newhostname.newdomain.tld newhostname localhost.localdomain localhost 127.0.0.1 newhostname.newdomain.tld newhostname localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 ::1 localhost6.localdomain6 localhost6
RESULT RESULT
@ -143,7 +143,7 @@ shared_examples 'swapping simple hostname in /etc/hosts' do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 newhostname.newdomain.tld newhostname oldhostname.nope localhost.localdomain localhost 127.0.0.1 newhostname.newdomain.tld newhostname oldhostname.nope localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 ::1 localhost6.localdomain6 localhost6
RESULT RESULT
@ -161,7 +161,7 @@ shared_examples 'swapping simple hostname in /etc/hosts' do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 newhostname localhost.localdomain localhost 127.0.0.1 newhostname localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 ::1 localhost6.localdomain6 localhost6
RESULT RESULT
@ -175,7 +175,7 @@ shared_examples 'swapping simple hostname in /etc/hosts' do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 newhostname oldhostname.nope localhost.localdomain localhost 127.0.0.1 newhostname oldhostname.nope localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 ::1 localhost6.localdomain6 localhost6
RESULT RESULT
@ -197,7 +197,7 @@ shared_examples 'swapping qualified hostname in /etc/hosts' do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 newhostname.newdomain.tld newhostname localhost.localdomain localhost 127.0.0.1 newhostname.newdomain.tld newhostname localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 ::1 localhost6.localdomain6 localhost6
RESULT RESULT
@ -211,7 +211,7 @@ shared_examples 'swapping qualified hostname in /etc/hosts' do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 newhostname.newdomain.tld newhostname oldhostname.nope localhost.localdomain localhost 127.0.0.1 newhostname.newdomain.tld newhostname oldhostname.nope localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 ::1 localhost6.localdomain6 localhost6
RESULT RESULT
@ -229,7 +229,7 @@ shared_examples 'swapping qualified hostname in /etc/hosts' do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 newhostname localhost.localdomain localhost 127.0.0.1 newhostname localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 ::1 localhost6.localdomain6 localhost6
RESULT RESULT
@ -243,7 +243,7 @@ shared_examples 'swapping qualified hostname in /etc/hosts' do
modified_etc_hosts = original_etc_hosts.gsub(search, replace) modified_etc_hosts = original_etc_hosts.gsub(search, replace)
modified_etc_hosts.should == <<-RESULT.gsub(/^ */, '') expect(modified_etc_hosts).to eq <<-RESULT.gsub(/^ */, '')
127.0.0.1 newhostname oldhostname.nope localhost.localdomain localhost 127.0.0.1 newhostname oldhostname.nope localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 ::1 localhost6.localdomain6 localhost6
RESULT RESULT

View File

@ -10,7 +10,7 @@ describe "VagrantPlugins::GuestUbuntu::Cap::ChangeHostName" do
let(:old_hostname) {'oldhostname.olddomain.tld' } let(:old_hostname) {'oldhostname.olddomain.tld' }
before do before do
machine.stub(:communicate).and_return(communicator) allow(machine).to receive(:communicate).and_return(communicator)
communicator.stub_command('hostname -f', stdout: old_hostname) communicator.stub_command('hostname -f', stdout: old_hostname)
end end

View File

@ -56,7 +56,7 @@ describe VagrantPlugins::HyperV::Provider do
it "calls an action to determine the ID" do it "calls an action to determine the ID" do
machine.stub(id: "foo") machine.stub(id: "foo")
machine.should_receive(:action).with(:read_state). expect(machine).to receive(:action).with(:read_state).
and_return({ machine_state_id: :bar }) and_return({ machine_state_id: :bar })
expect(subject.state.id).to eq(:bar) expect(subject.state.id).to eq(:bar)

View File

@ -32,7 +32,7 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSSettings do
action = described_class.new(app, env) action = described_class.new(app, env)
action.call(env) action.call(env)
called.should == true expect(called).to eq(true)
end end
context "with an nfs synced folder" do context "with an nfs synced folder" do
@ -50,22 +50,22 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSSettings do
driver.stub(read_host_only_interfaces: [ driver.stub(read_host_only_interfaces: [
{name: "vmnet2", ip: "1.2.3.4"}, {name: "vmnet2", ip: "1.2.3.4"},
]) ])
driver.stub(:read_guest_ip).with(1).and_return("2.3.4.5") allow(driver).to receive(:read_guest_ip).with(1).and_return("2.3.4.5")
# override sleep to 0 so test does not take seconds # override sleep to 0 so test does not take seconds
retry_options = subject.retry_options retry_options = subject.retry_options
subject.stub(:retry_options).and_return(retry_options.merge(sleep: 0)) allow(subject).to receive(:retry_options).and_return(retry_options.merge(sleep: 0))
end end
it "sets nfs_host_ip and nfs_machine_ip properly" do it "sets nfs_host_ip and nfs_machine_ip properly" do
subject.call(env) subject.call(env)
env[:nfs_host_ip].should == "1.2.3.4" expect(env[:nfs_host_ip]).to eq("1.2.3.4")
env[:nfs_machine_ip].should == "2.3.4.5" expect(env[:nfs_machine_ip]).to eq("2.3.4.5")
end end
it "raises an error when no host only adapter is configured" do it "raises an error when no host only adapter is configured" do
driver.stub(:read_network_interfaces) {{}} allow(driver).to receive(:read_network_interfaces) {{}}
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::NFSNoHostonlyNetwork) to raise_error(Vagrant::Errors::NFSNoHostonlyNetwork)
@ -76,16 +76,16 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSSettings do
lambda { raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound, :guest_property => 'stub' }, lambda { raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound, :guest_property => 'stub' },
lambda { "2.3.4.5" } lambda { "2.3.4.5" }
] ]
driver.stub(:read_guest_ip) { raise_then_return.shift.call } allow(driver).to receive(:read_guest_ip) { raise_then_return.shift.call }
subject.call(env) subject.call(env)
env[:nfs_host_ip].should == "1.2.3.4" expect(env[:nfs_host_ip]).to eq("1.2.3.4")
env[:nfs_machine_ip].should == "2.3.4.5" expect(env[:nfs_machine_ip]).to eq("2.3.4.5")
end end
it "raises an error informing the user of a bug when the guest IP cannot be found" do it "raises an error informing the user of a bug when the guest IP cannot be found" do
driver.stub(:read_guest_ip) { allow(driver).to receive(:read_guest_ip) {
raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound, :guest_property => 'stub' raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound, :guest_property => 'stub'
} }
@ -96,14 +96,14 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSSettings do
it "allows statically configured guest IPs to work for NFS, even when guest property would fail" do it "allows statically configured guest IPs to work for NFS, even when guest property would fail" do
env[:machine].config.vm.network :private_network, ip: "11.12.13.14" env[:machine].config.vm.network :private_network, ip: "11.12.13.14"
driver.stub(:read_guest_ip) { allow(driver).to receive(:read_guest_ip) {
raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound, :guest_property => "stub" raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound, :guest_property => "stub"
} }
subject.call(env) subject.call(env)
env[:nfs_host_ip].should == "1.2.3.4" expect(env[:nfs_host_ip]).to eq("1.2.3.4")
env[:nfs_machine_ip].should == ["11.12.13.14"] expect(env[:nfs_machine_ip]).to eq(["11.12.13.14"])
end end
end end
end end

View File

@ -34,7 +34,7 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSValidIds do
action = described_class.new(app, env) action = described_class.new(app, env)
action.call(env) action.call(env)
called.should == true expect(called).to eq(true)
end end
it "sets nfs_valid_ids" do it "sets nfs_valid_ids" do

View File

@ -22,7 +22,7 @@ describe VagrantPlugins::ProviderVirtualBox::Cap do
describe "#forwarded_ports" do describe "#forwarded_ports" do
it "returns all the forwarded ports" do it "returns all the forwarded ports" do
driver.should_receive(:read_forwarded_ports).and_return([ expect(driver).to receive(:read_forwarded_ports).and_return([
[nil, nil, 123, 456], [nil, nil, 123, 456],
[nil, nil, 245, 245], [nil, nil, 245, 245],
]) ])

View File

@ -6,9 +6,20 @@ describe VagrantPlugins::ProviderVirtualBox::Config do
context "defaults" do context "defaults" do
before { subject.finalize! } before { subject.finalize! }
its(:check_guest_additions) { should be_true } describe '#check_guest_additions' do
its(:gui) { should be_false } subject { super().check_guest_additions }
its(:name) { should be_nil } it { should be_true }
end
describe '#gui' do
subject { super().gui }
it { should be_false }
end
describe '#name' do
subject { super().name }
it { should be_nil }
end
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

@ -7,17 +7,17 @@ shared_examples "a version 4.x virtualbox driver" do |options|
it "reads the guest property of the machine referenced by the UUID" do it "reads the guest property of the machine referenced by the UUID" do
key = "/Foo/Bar" key = "/Foo/Bar"
subprocess.should_receive(:execute). expect(subprocess).to receive(:execute).
with("VBoxManage", "guestproperty", "get", uuid, key, an_instance_of(Hash)). with("VBoxManage", "guestproperty", "get", uuid, key, an_instance_of(Hash)).
and_return(subprocess_result(stdout: "Value: Baz\n")) and_return(subprocess_result(stdout: "Value: Baz\n"))
subject.read_guest_property(key).should == "Baz" expect(subject.read_guest_property(key)).to eq("Baz")
end end
it "raises a virtualBoxGuestPropertyNotFound exception when the value is not set" do it "raises a virtualBoxGuestPropertyNotFound exception when the value is not set" do
key = "/Not/There" key = "/Not/There"
subprocess.should_receive(:execute). expect(subprocess).to receive(:execute).
with("VBoxManage", "guestproperty", "get", uuid, key, an_instance_of(Hash)). with("VBoxManage", "guestproperty", "get", uuid, key, an_instance_of(Hash)).
and_return(subprocess_result(stdout: "No value set!")) and_return(subprocess_result(stdout: "No value set!"))
@ -30,13 +30,13 @@ shared_examples "a version 4.x virtualbox driver" do |options|
it "reads the guest property for the provided adapter number" do it "reads the guest property for the provided adapter number" do
key = "/VirtualBox/GuestInfo/Net/1/V4/IP" key = "/VirtualBox/GuestInfo/Net/1/V4/IP"
subprocess.should_receive(:execute). expect(subprocess).to receive(:execute).
with("VBoxManage", "guestproperty", "get", uuid, key, an_instance_of(Hash)). with("VBoxManage", "guestproperty", "get", uuid, key, an_instance_of(Hash)).
and_return(subprocess_result(stdout: "Value: 127.1.2.3")) and_return(subprocess_result(stdout: "Value: 127.1.2.3"))
value = subject.read_guest_ip(1) value = subject.read_guest_ip(1)
value.should == "127.1.2.3" expect(value).to eq("127.1.2.3")
end end
end end
end end

View File

@ -14,12 +14,12 @@ describe VagrantPlugins::ProviderVirtualBox::SyncedFolder do
describe "usable" do describe "usable" do
it "should be with virtualbox provider" do it "should be with virtualbox provider" do
machine.stub(provider_name: :virtualbox) machine.stub(provider_name: :virtualbox)
subject.should be_usable(machine) expect(subject).to be_usable(machine)
end end
it "should not be with another provider" do it "should not be with another provider" do
machine.stub(provider_name: :vmware_fusion) machine.stub(provider_name: :vmware_fusion)
subject.should_not be_usable(machine) expect(subject).not_to be_usable(machine)
end end
end end

View File

@ -15,18 +15,18 @@ describe VagrantPlugins::Chef::Provisioner::Base do
let(:root_path) { "/my/root" } let(:root_path) { "/my/root" }
before do before do
machine.stub(:env).and_return(env) allow(machine).to receive(:env).and_return(env)
env.stub(:root_path).and_return(root_path) allow(env).to receive(:root_path).and_return(root_path)
end end
it "returns absolute path as is" do it "returns absolute path as is" do
config.should_receive(:encrypted_data_bag_secret_key_path). expect(config).to receive(:encrypted_data_bag_secret_key_path).
and_return("/foo/bar") and_return("/foo/bar")
expect(subject.encrypted_data_bag_secret_key_path).to eq "/foo/bar" expect(subject.encrypted_data_bag_secret_key_path).to eq "/foo/bar"
end end
it "returns relative path joined to root_path" do it "returns relative path joined to root_path" do
config.should_receive(:encrypted_data_bag_secret_key_path). expect(config).to receive(:encrypted_data_bag_secret_key_path).
and_return("secret") and_return("secret")
expect(subject.encrypted_data_bag_secret_key_path).to eq "/my/root/secret" expect(subject.encrypted_data_bag_secret_key_path).to eq "/my/root/secret"
end end
@ -34,14 +34,14 @@ describe VagrantPlugins::Chef::Provisioner::Base do
describe "#guest_encrypted_data_bag_secret_key_path" do describe "#guest_encrypted_data_bag_secret_key_path" do
it "returns nil if host path is not configured" do it "returns nil if host path is not configured" do
config.stub(:encrypted_data_bag_secret_key_path).and_return(nil) allow(config).to receive(:encrypted_data_bag_secret_key_path).and_return(nil)
config.stub(:provisioning_path).and_return("/tmp/foo") allow(config).to receive(:provisioning_path).and_return("/tmp/foo")
expect(subject.guest_encrypted_data_bag_secret_key_path).to be_nil expect(subject.guest_encrypted_data_bag_secret_key_path).to be_nil
end end
it "returns path under config.provisioning_path" do it "returns path under config.provisioning_path" do
config.stub(:encrypted_data_bag_secret_key_path).and_return("secret") allow(config).to receive(:encrypted_data_bag_secret_key_path).and_return("secret")
config.stub(:provisioning_path).and_return("/tmp/foo") allow(config).to receive(:provisioning_path).and_return("/tmp/foo")
expect(File.dirname(subject.guest_encrypted_data_bag_secret_key_path)). expect(File.dirname(subject.guest_encrypted_data_bag_secret_key_path)).
to eq "/tmp/foo" to eq "/tmp/foo"
end end

View File

@ -17,7 +17,7 @@ describe "VagrantPlugins::Shell::Config" do
result = subject.validate(machine) result = subject.validate(machine)
result["shell provisioner"].should == [] expect(result["shell provisioner"]).to eq([])
end end
it "passes with string args" do it "passes with string args" do
@ -27,7 +27,7 @@ describe "VagrantPlugins::Shell::Config" do
result = subject.validate(machine) result = subject.validate(machine)
result["shell provisioner"].should == [] expect(result["shell provisioner"]).to eq([])
end end
it "passes with fixnum args" do it "passes with fixnum args" do
@ -37,7 +37,7 @@ describe "VagrantPlugins::Shell::Config" do
result = subject.validate(machine) result = subject.validate(machine)
result["shell provisioner"].should == [] expect(result["shell provisioner"]).to eq([])
end end
it "passes with array args" do it "passes with array args" do
@ -47,7 +47,7 @@ describe "VagrantPlugins::Shell::Config" do
result = subject.validate(machine) result = subject.validate(machine)
result["shell provisioner"].should == [] expect(result["shell provisioner"]).to eq([])
end end
it "returns an error if args is neither a string nor an array" do it "returns an error if args is neither a string nor an array" do
@ -59,9 +59,9 @@ describe "VagrantPlugins::Shell::Config" do
result = subject.validate(machine) result = subject.validate(machine)
result["shell provisioner"].should == [ expect(result["shell provisioner"]).to eq([
I18n.t("vagrant.provisioners.shell.args_bad_type") I18n.t("vagrant.provisioners.shell.args_bad_type")
] ])
end end
it "handles scalar array args" do it "handles scalar array args" do
@ -71,7 +71,7 @@ describe "VagrantPlugins::Shell::Config" do
result = subject.validate(machine) result = subject.validate(machine)
result["shell provisioner"].should == [] expect(result["shell provisioner"]).to eq([])
end end
it "returns an error if args is an array with non-scalar types" do it "returns an error if args is an array with non-scalar types" do
@ -81,9 +81,9 @@ describe "VagrantPlugins::Shell::Config" do
result = subject.validate(machine) result = subject.validate(machine)
result["shell provisioner"].should == [ expect(result["shell provisioner"]).to eq([
I18n.t("vagrant.provisioners.shell.args_bad_type") I18n.t("vagrant.provisioners.shell.args_bad_type")
] ])
end end
end end
end end

View File

@ -27,14 +27,14 @@ describe VagrantPlugins::SyncedFolderNFS::ActionCleanup do
end end
it "does nothing if there are no valid IDs" do it "does nothing if there are no valid IDs" do
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
it "does nothing if the host doesn't support pruning NFS" do it "does nothing if the host doesn't support pruning NFS" do
host.stub(:capability?).with(:nfs_prune).and_return(false) allow(host).to receive(:capability?).with(:nfs_prune).and_return(false)
host.should_receive(:capability).never expect(host).to receive(:capability).never
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -42,9 +42,9 @@ describe VagrantPlugins::SyncedFolderNFS::ActionCleanup do
it "prunes the NFS entries if valid IDs are given" do it "prunes the NFS entries if valid IDs are given" do
env[:nfs_valid_ids] = [1,2,3] env[:nfs_valid_ids] = [1,2,3]
host.stub(:capability?).with(:nfs_prune).and_return(true) allow(host).to receive(:capability?).with(:nfs_prune).and_return(true)
host.should_receive(:capability).with(:nfs_prune, machine.ui, [1,2,3]).ordered expect(host).to receive(:capability).with(:nfs_prune, machine.ui, [1,2,3]).ordered
app.should_receive(:call).with(env).ordered expect(app).to receive(:call).with(env).ordered
subject.call(env) subject.call(env)
end end

View File

@ -43,7 +43,7 @@ describe VagrantPlugins::SyncedFolderRSync::Command::RsyncAuto do
] ]
paths["/foo"].each do |data| paths["/foo"].each do |data|
helper_class.should_receive(:rsync_single). expect(helper_class).to receive(:rsync_single).
with(data[:machine], data[:machine].ssh_info, data[:opts]). with(data[:machine], data[:machine].ssh_info, data[:opts]).
once once
end end
@ -64,7 +64,7 @@ describe VagrantPlugins::SyncedFolderRSync::Command::RsyncAuto do
] ]
paths["/foo"].each do |data| paths["/foo"].each do |data|
helper_class.should_receive(:rsync_single). expect(helper_class).to receive(:rsync_single).
with(data[:machine], data[:machine].ssh_info, data[:opts]). with(data[:machine], data[:machine].ssh_info, data[:opts]).
once once
end end
@ -85,7 +85,7 @@ describe VagrantPlugins::SyncedFolderRSync::Command::RsyncAuto do
] ]
paths["/foo"].each do |data| paths["/foo"].each do |data|
helper_class.should_receive(:rsync_single). expect(helper_class).to receive(:rsync_single).
with(data[:machine], data[:machine].ssh_info, data[:opts]). with(data[:machine], data[:machine].ssh_info, data[:opts]).
once once
end end

View File

@ -53,14 +53,14 @@ describe VagrantPlugins::SyncedFolderRSync::Command::Rsync do
it "doesn't sync if communicator isn't ready and exits with 1" do it "doesn't sync if communicator isn't ready and exits with 1" do
communicator.stub(ready?: false) communicator.stub(ready?: false)
helper_class.should_receive(:rsync_single).never expect(helper_class).to receive(:rsync_single).never
expect(subject.execute).to eql(1) expect(subject.execute).to eql(1)
end end
it "rsyncs each folder and exits successfully" do it "rsyncs each folder and exits successfully" do
synced_folders[:rsync].each do |_, opts| synced_folders[:rsync].each do |_, opts|
helper_class.should_receive(:rsync_single). expect(helper_class).to receive(:rsync_single).
with(machine, ssh_info, opts). with(machine, ssh_info, opts).
ordered ordered
end end

View File

@ -23,7 +23,7 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
machine.stub(guest: guest) machine.stub(guest: guest)
# Don't do all the crazy Cygwin stuff # Don't do all the crazy Cygwin stuff
Vagrant::Util::Platform.stub(:cygwin_path) do |path, **opts| allow(Vagrant::Util::Platform).to receive(:cygwin_path) do |path, **opts|
path path
end end
end end
@ -75,17 +75,17 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
it "doesn't call cygwin_path on non-Windows" do it "doesn't call cygwin_path on non-Windows" do
Vagrant::Util::Platform.stub(windows?: false) Vagrant::Util::Platform.stub(windows?: false)
Vagrant::Util::Platform.should_not_receive(:cygwin_path) expect(Vagrant::Util::Platform).not_to receive(:cygwin_path)
subject.rsync_single(machine, ssh_info, opts) subject.rsync_single(machine, ssh_info, opts)
end end
it "calls cygwin_path on Windows" do it "calls cygwin_path on Windows" do
Vagrant::Util::Platform.stub(windows?: true) Vagrant::Util::Platform.stub(windows?: true)
Vagrant::Util::Platform.should_receive(:cygwin_path).and_return("foo") expect(Vagrant::Util::Platform).to receive(:cygwin_path).and_return("foo")
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args| expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
expect(args[args.length - 3]).to eql("foo/") expect(args[args.length - 3]).to eql("foo/")
end }
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"
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args| expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*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")
end }
subject.rsync_single(machine, ssh_info, opts) subject.rsync_single(machine, ssh_info, opts)
end end
@ -118,38 +118,38 @@ 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)
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args| expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*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")
end }
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
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args| expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*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)
end }
subject.rsync_single(machine, ssh_info, opts) subject.rsync_single(machine, ssh_info, opts)
end end
it "executes the rsync_pre capability first if it exists" do it "executes the rsync_pre capability first if it exists" do
guest.should_receive(:capability?).with(:rsync_pre).and_return(true) expect(guest).to receive(:capability?).with(:rsync_pre).and_return(true)
guest.should_receive(:capability).with(:rsync_pre, opts).ordered expect(guest).to receive(:capability).with(:rsync_pre, opts).ordered
Vagrant::Util::Subprocess.should_receive(:execute).ordered.and_return(result) expect(Vagrant::Util::Subprocess).to receive(:execute).ordered.and_return(result)
subject.rsync_single(machine, ssh_info, opts) subject.rsync_single(machine, ssh_info, opts)
end end
it "executes the rsync_post capability after if it exists" do it "executes the rsync_post capability after if it exists" do
guest.should_receive(:capability?).with(:rsync_post).and_return(true) expect(guest).to receive(:capability?).with(:rsync_post).and_return(true)
Vagrant::Util::Subprocess.should_receive(:execute).ordered.and_return(result) expect(Vagrant::Util::Subprocess).to receive(:execute).ordered.and_return(result)
guest.should_receive(:capability).with(:rsync_post, opts).ordered expect(guest).to receive(:capability).with(:rsync_post, opts).ordered
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"
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args| expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*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")
end }
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"]
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args| expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*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")
end }
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
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args| expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*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}/")
end }
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"]
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args| expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*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}/")
end }
subject.rsync_single(machine, ssh_info, opts) subject.rsync_single(machine, ssh_info, opts)
end end

View File

@ -25,17 +25,17 @@ 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
Vagrant::Util::Which.should_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
Vagrant::Util::Which.should_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
Vagrant::Util::Which.should_receive(:which).with("rsync").and_return(false) expect(Vagrant::Util::Which).to receive(:which).with("rsync").and_return(false)
expect { subject.usable?(machine, true) }. expect { subject.usable?(machine, true) }.
to raise_error(Vagrant::Errors::RSyncNotFound) to raise_error(Vagrant::Errors::RSyncNotFound)
end end
@ -48,7 +48,7 @@ describe VagrantPlugins::SyncedFolderRSync::SyncedFolder do
before do before do
machine.stub(ssh_info: ssh_info) machine.stub(ssh_info: ssh_info)
guest.stub(:capability?).with(:rsync_installed) allow(guest).to receive(:capability?).with(:rsync_installed)
end end
it "rsyncs each folder" do it "rsyncs each folder" do
@ -58,7 +58,7 @@ describe VagrantPlugins::SyncedFolderRSync::SyncedFolder do
] ]
folders.each do |_, opts| folders.each do |_, opts|
helper_class.should_receive(:rsync_single). expect(helper_class).to receive(:rsync_single).
with(machine, ssh_info, opts). with(machine, ssh_info, opts).
ordered ordered
end end
@ -69,10 +69,10 @@ describe VagrantPlugins::SyncedFolderRSync::SyncedFolder do
it "installs rsync if capable" do it "installs rsync if capable" do
folders = [ [:foo, {}] ] folders = [ [:foo, {}] ]
helper_class.stub(:rsync_single) allow(helper_class).to receive(:rsync_single)
guest.stub(:capability?).with(:rsync_installed).and_return(true) allow(guest).to receive(:capability?).with(:rsync_installed).and_return(true)
guest.stub(:capability?).with(:rsync_install).and_return(true) allow(guest).to receive(:capability?).with(:rsync_install).and_return(true)
expect(guest).to receive(:capability).with(:rsync_installed).and_return(false) expect(guest).to receive(:capability).with(:rsync_installed).and_return(false)
expect(guest).to receive(:capability).with(:rsync_install) expect(guest).to receive(:capability).with(:rsync_install)
@ -83,10 +83,10 @@ describe VagrantPlugins::SyncedFolderRSync::SyncedFolder do
it "errors if rsync not installable" do it "errors if rsync not installable" do
folders = [ [:foo, {}] ] folders = [ [:foo, {}] ]
helper_class.stub(:rsync_single) allow(helper_class).to receive(:rsync_single)
guest.stub(:capability?).with(:rsync_installed).and_return(true) allow(guest).to receive(:capability?).with(:rsync_installed).and_return(true)
guest.stub(:capability?).with(:rsync_install).and_return(false) allow(guest).to receive(:capability?).with(:rsync_install).and_return(false)
expect(guest).to receive(:capability).with(:rsync_installed).and_return(false) expect(guest).to receive(:capability).with(:rsync_installed).and_return(false)

View File

@ -20,12 +20,12 @@ shared_context "virtualbox" do
# drivers will blow up on instantiation if they cannot determine the # drivers will blow up on instantiation if they cannot determine the
# virtualbox version, so wire this stub in automatically # virtualbox version, so wire this stub in automatically
subprocess.stub(:execute). allow(subprocess).to receive(:execute).
with("VBoxManage", "--version", an_instance_of(Hash)). with("VBoxManage", "--version", an_instance_of(Hash)).
and_return(subprocess_result(stdout: vbox_version)) and_return(subprocess_result(stdout: vbox_version))
# drivers also call vm_exists? during init; # drivers also call vm_exists? during init;
subprocess.stub(:execute). allow(subprocess).to receive(:execute).
with("VBoxManage", "showvminfo", kind_of(String), kind_of(Hash)). with("VBoxManage", "showvminfo", kind_of(String), kind_of(Hash)).
and_return(subprocess_result(exit_code: 0)) and_return(subprocess_result(exit_code: 0))
end end

View File

@ -19,7 +19,7 @@ describe Vagrant::Action::Builder do
context "copying" do context "copying" do
it "should copy the stack" do it "should copy the stack" do
copy = subject.dup copy = subject.dup
copy.stack.object_id.should_not == subject.stack.object_id expect(copy.stack.object_id).not_to eq(subject.stack.object_id)
end end
end end
@ -31,7 +31,7 @@ describe Vagrant::Action::Builder do
subject = described_class.build(proc) subject = described_class.build(proc)
subject.call(data) subject.call(data)
data[:data].should == true expect(data[:data]).to eq(true)
end end
end end
@ -43,7 +43,7 @@ describe Vagrant::Action::Builder do
subject.use proc subject.use proc
subject.call(data) subject.call(data)
data[:data].should == true expect(data[:data]).to eq(true)
end end
it "should be able to add multiple items" do it "should be able to add multiple items" do
@ -55,8 +55,8 @@ describe Vagrant::Action::Builder do
subject.use proc2 subject.use proc2
subject.call(data) subject.call(data)
data[:one].should == true expect(data[:one]).to eq(true)
data[:two].should == true expect(data[:two]).to eq(true)
end end
it "should be able to add another builder" do it "should be able to add another builder" do
@ -73,7 +73,7 @@ describe Vagrant::Action::Builder do
# Call the 2nd and verify results # Call the 2nd and verify results
two.call(data) two.call(data)
data[:one].should == true expect(data[:one]).to eq(true)
end end
end end
@ -83,7 +83,7 @@ describe Vagrant::Action::Builder do
subject.insert(0, appender_proc(2)) subject.insert(0, appender_proc(2))
subject.call(data) subject.call(data)
data[:data].should == [2, 1] expect(data[:data]).to eq([2, 1])
end end
it "can insert by name" do it "can insert by name" do
@ -96,7 +96,7 @@ describe Vagrant::Action::Builder do
subject.insert_before :bar, appender_proc(3) subject.insert_before :bar, appender_proc(3)
subject.call(data) subject.call(data)
data[:data].should == [1, 3, 2] expect(data[:data]).to eq([1, 3, 2])
end end
it "can insert next to a previous object" do it "can insert next to a previous object" do
@ -106,7 +106,7 @@ describe Vagrant::Action::Builder do
subject.insert(proc2, appender_proc(3)) subject.insert(proc2, appender_proc(3))
subject.call(data) subject.call(data)
data[:data].should == [1, 3, 2] expect(data[:data]).to eq([1, 3, 2])
end end
it "can insert before" do it "can insert before" do
@ -114,7 +114,7 @@ describe Vagrant::Action::Builder do
subject.insert_before 0, appender_proc(2) subject.insert_before 0, appender_proc(2)
subject.call(data) subject.call(data)
data[:data].should == [2, 1] expect(data[:data]).to eq([2, 1])
end end
it "can insert after" do it "can insert after" do
@ -123,7 +123,7 @@ describe Vagrant::Action::Builder do
subject.insert_after 0, appender_proc(2) subject.insert_after 0, appender_proc(2)
subject.call(data) subject.call(data)
data[:data].should == [1, 2, 3] expect(data[:data]).to eq([1, 2, 3])
end end
it "merges middleware stacks of other builders" do it "merges middleware stacks of other builders" do
@ -152,7 +152,7 @@ describe Vagrant::Action::Builder do
subject.insert(proc2, builder) subject.insert(proc2, builder)
subject.call(data) subject.call(data)
data[:data].should == [1, "A1", "B1", 2, "B2", "A2"] expect(data[:data]).to eq([1, "A1", "B1", 2, "B2", "A2"])
end end
it "raises an exception if an invalid object given for insert" do it "raises an exception if an invalid object given for insert" do
@ -175,7 +175,7 @@ describe Vagrant::Action::Builder do
subject.replace proc1, proc2 subject.replace proc1, proc2
subject.call(data) subject.call(data)
data[:data].should == [2] expect(data[:data]).to eq([2])
end end
it "can replace by index" do it "can replace by index" do
@ -186,7 +186,7 @@ describe Vagrant::Action::Builder do
subject.replace 0, proc2 subject.replace 0, proc2
subject.call(data) subject.call(data)
data[:data].should == [2] expect(data[:data]).to eq([2])
end end
end end
@ -199,7 +199,7 @@ describe Vagrant::Action::Builder do
subject.delete proc1 subject.delete proc1
subject.call(data) subject.call(data)
data[:data].should == [2] expect(data[:data]).to eq([2])
end end
it "can delete by index" do it "can delete by index" do
@ -210,14 +210,14 @@ describe Vagrant::Action::Builder do
subject.delete 0 subject.delete 0
subject.call(data) subject.call(data)
data[:data].should == [2] expect(data[:data]).to eq([2])
end end
end end
describe "action hooks" do describe "action hooks" do
it "applies them properly" do it "applies them properly" do
hook = double("hook") hook = double("hook")
hook.stub(:apply) do |builder| allow(hook).to receive(:apply) do |builder|
builder.use appender_proc(2) builder.use appender_proc(2)
end end
@ -226,13 +226,13 @@ describe Vagrant::Action::Builder do
subject.use appender_proc(1) subject.use appender_proc(1)
subject.call(data) subject.call(data)
data[:data].should == [1, 2] expect(data[:data]).to eq([1, 2])
data[:action_hooks_already_ran].should == true expect(data[:action_hooks_already_ran]).to eq(true)
end end
it "applies without prepend/append if it has already" do it "applies without prepend/append if it has already" do
hook = double("hook") hook = double("hook")
hook.should_receive(:apply).with(anything, { :no_prepend_or_append => true }).once expect(hook).to receive(:apply).with(anything, { :no_prepend_or_append => true }).once
data[:action_hooks] = [hook] data[:action_hooks] = [hook]
data[:action_hooks_already_ran] = true data[:action_hooks_already_ran] = true

View File

@ -66,15 +66,15 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_name] = "foo" env[:box_name] = "foo"
env[:box_url] = box_path.to_s env[:box_url] = box_path.to_s
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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")
expect(opts[:metadata_url]).to be_nil expect(opts[:metadata_url]).to be_nil
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -88,15 +88,15 @@ describe Vagrant::Action::Builtin::BoxAdd do
box_path.to_s, box_path.to_s,
] ]
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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")
expect(opts[:metadata_url]).to be_nil expect(opts[:metadata_url]).to be_nil
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -107,15 +107,15 @@ describe Vagrant::Action::Builtin::BoxAdd 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}"
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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")
expect(opts[:metadata_url]).to be_nil expect(opts[:metadata_url]).to be_nil
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -126,8 +126,8 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_url] = box_path.to_s env[:box_url] = box_path.to_s
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxAddNameRequired) to raise_error(Vagrant::Errors::BoxAddNameRequired)
@ -140,10 +140,10 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_url] = box_path.to_s env[:box_url] = box_path.to_s
env[:box_provider] = "virtualbox" env[:box_provider] = "virtualbox"
box_collection.should_receive(:find).with( expect(box_collection).to receive(:find).with(
"foo", ["virtualbox"], "0").and_return(box) "foo", ["virtualbox"], "0").and_return(box)
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxAlreadyExists) to raise_error(Vagrant::Errors::BoxAlreadyExists)
@ -157,8 +157,8 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_checksum] = checksum(box_path) + "A" env[:box_checksum] = checksum(box_path) + "A"
env[:box_checksum_type] = "sha1" env[:box_checksum_type] = "sha1"
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxChecksumMismatch) to raise_error(Vagrant::Errors::BoxChecksumMismatch)
@ -170,8 +170,8 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_name] = "foo" env[:box_name] = "foo"
env[:box_url] = box_path.to_s + "nope" env[:box_url] = box_path.to_s + "nope"
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::DownloaderError) to raise_error(Vagrant::Errors::DownloaderError)
@ -186,14 +186,14 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_provider] = "virtualbox" env[:box_provider] = "virtualbox"
box_collection.stub(find: box) box_collection.stub(find: box)
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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")
expect(opts[:metadata_url]).to be_nil expect(opts[:metadata_url]).to be_nil
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
subject.call(env) subject.call(env)
end end
@ -229,15 +229,15 @@ describe Vagrant::Action::Builtin::BoxAdd 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}"
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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))
expect(opts[:metadata_url]).to eq(env[:box_url]) expect(opts[:metadata_url]).to eq(env[:box_url])
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -274,16 +274,16 @@ describe Vagrant::Action::Builtin::BoxAdd 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"
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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))
expect(opts[:metadata_url]).to eq( expect(opts[:metadata_url]).to eq(
"#{url}/#{env[:box_url]}") "#{url}/#{env[:box_url]}")
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
with_temp_env("VAGRANT_SERVER_URL" => url) do with_temp_env("VAGRANT_SERVER_URL" => url) do
subject.call(env) subject.call(env)
@ -324,7 +324,7 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_url] = "foo" env[:box_url] = "foo"
env[:hook] = double("hook") env[:hook] = double("hook")
env[:hook].stub(:call) do |name, opts| allow(env[:hook]).to receive(:call) do |name, opts|
expect(name).to eq(:authenticate_box_url) expect(name).to eq(:authenticate_box_url)
if opts[:box_urls] == ["foo"] if opts[:box_urls] == ["foo"]
next { box_urls: [real_url] } next { box_urls: [real_url] }
@ -335,15 +335,15 @@ describe Vagrant::Action::Builtin::BoxAdd do
end end
end end
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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))
expect(opts[:metadata_url]).to eq(env[:box_url]) expect(opts[:metadata_url]).to eq(env[:box_url])
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -380,15 +380,15 @@ describe Vagrant::Action::Builtin::BoxAdd 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}"
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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))
expect(opts[:metadata_url]).to eq(env[:box_url]) expect(opts[:metadata_url]).to eq(env[:box_url])
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -425,8 +425,8 @@ describe Vagrant::Action::Builtin::BoxAdd 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}"
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxChecksumMismatch) to raise_error(Vagrant::Errors::BoxChecksumMismatch)
@ -439,8 +439,8 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_url] = "mitchellh/precise64.json" env[:box_url] = "mitchellh/precise64.json"
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
Vagrant.stub(server_url: nil) Vagrant.stub(server_url: nil)
@ -455,8 +455,8 @@ describe Vagrant::Action::Builtin::BoxAdd do
with_web_server(Pathname.new(tf.path)) do |port| with_web_server(Pathname.new(tf.path)) do |port|
env[:box_url] = "mitchellh/precise64.json" env[:box_url] = "mitchellh/precise64.json"
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
url = "http://127.0.0.1:#{port}" url = "http://127.0.0.1:#{port}"
with_temp_env("VAGRANT_SERVER_URL" => url) do with_temp_env("VAGRANT_SERVER_URL" => url) do
@ -495,8 +495,8 @@ describe Vagrant::Action::Builtin::BoxAdd do
"/foo/bar/baz", "/foo/bar/baz",
tf.path, tf.path,
] ]
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxAddMetadataMultiURL) to raise_error(Vagrant::Errors::BoxAddMetadataMultiURL)
@ -528,15 +528,15 @@ describe Vagrant::Action::Builtin::BoxAdd do
end end
env[:box_url] = tf.path env[:box_url] = tf.path
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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[:metadata_url]).to eq("file://#{tf.path}") expect(opts[:metadata_url]).to eq("file://#{tf.path}")
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -572,15 +572,15 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_url] = tf.path env[:box_url] = tf.path
env[:box_provider] = "vmware" env[:box_provider] = "vmware"
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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[:metadata_url]).to eq("file://#{tf.path}") expect(opts[:metadata_url]).to eq("file://#{tf.path}")
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
@ -621,15 +621,15 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_url] = tf.path env[:box_url] = tf.path
env[:box_provider] = "vmware" env[:box_provider] = "vmware"
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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[:metadata_url]).to eq("file://#{tf.path}") expect(opts[:metadata_url]).to eq("file://#{tf.path}")
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
@ -661,15 +661,15 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_url] = tf.path env[:box_url] = tf.path
env[:box_version] = "~> 0.1" env[:box_version] = "~> 0.1"
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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")
expect(opts[:metadata_url]).to eq("file://#{tf.path}") expect(opts[:metadata_url]).to eq("file://#{tf.path}")
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
@ -706,15 +706,15 @@ describe Vagrant::Action::Builtin::BoxAdd 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"
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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")
expect(opts[:metadata_url]).to eq("file://#{tf.path}") expect(opts[:metadata_url]).to eq("file://#{tf.path}")
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
@ -754,15 +754,15 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_url] = tf.path env[:box_url] = tf.path
env[:box_provider] = ["virtualbox", "vmware"] env[:box_provider] = ["virtualbox", "vmware"]
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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[:metadata_url]).to eq("file://#{tf.path}") expect(opts[:metadata_url]).to eq("file://#{tf.path}")
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
@ -800,17 +800,17 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_url] = tf.path env[:box_url] = tf.path
env[:ui].should_receive(:ask).and_return("1") expect(env[:ui]).to receive(:ask).and_return("1")
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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[:metadata_url]).to eq("file://#{tf.path}") expect(opts[:metadata_url]).to eq("file://#{tf.path}")
true true
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -843,8 +843,8 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_name] = "foo" env[:box_name] = "foo"
env[:box_url] = tf.path env[:box_url] = tf.path
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxAddNameMismatch) to raise_error(Vagrant::Errors::BoxAddNameMismatch)
@ -875,8 +875,8 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_url] = tf.path env[:box_url] = tf.path
env[:box_version] = "~> 2.0" env[:box_version] = "~> 2.0"
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxAddNoMatchingVersion) to raise_error(Vagrant::Errors::BoxAddNoMatchingVersion)
@ -908,8 +908,8 @@ describe Vagrant::Action::Builtin::BoxAdd do
env[:box_url] = tf.path env[:box_url] = tf.path
env[:box_provider] = "vmware" env[:box_provider] = "vmware"
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxAddNoMatchingProvider) to raise_error(Vagrant::Errors::BoxAddNoMatchingProvider)
@ -941,10 +941,10 @@ describe Vagrant::Action::Builtin::BoxAdd do
end end
env[:box_url] = tf.path env[:box_url] = tf.path
box_collection.should_receive(:find). expect(box_collection).to receive(:find).
with("foo/bar", "virtualbox", "0.7").and_return(box) with("foo/bar", "virtualbox", "0.7").and_return(box)
box_collection.should_receive(:add).never expect(box_collection).to receive(:add).never
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxAlreadyExists) to raise_error(Vagrant::Errors::BoxAlreadyExists)
@ -978,16 +978,16 @@ describe Vagrant::Action::Builtin::BoxAdd 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)
box_collection.should_receive(:add).with do |path, name, version, **opts| expect(box_collection).to receive(:add).with { |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
end.and_return(box) }.and_return(box)
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)

View File

@ -42,7 +42,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
it "doesn't check" do it "doesn't check" do
machine.config.vm.box_check_update = false machine.config.vm.box_check_update = false
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
subject.call(env) subject.call(env)
@ -53,7 +53,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
machine.config.vm.box_check_update = false machine.config.vm.box_check_update = false
env[:box_outdated_force] = true env[:box_outdated_force] = true
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
subject.call(env) subject.call(env)
@ -65,7 +65,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
it "raises an exception if the machine doesn't have a box yet" do it "raises an exception if the machine doesn't have a box yet" do
machine.stub(box: nil) machine.stub(box: nil)
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxOutdatedNoBox) to raise_error(Vagrant::Errors::BoxOutdatedNoBox)
@ -77,8 +77,8 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
box.stub(metadata_url: nil) box.stub(metadata_url: nil)
box.stub(version: "0") box.stub(version: "0")
app.should_receive(:call).once expect(app).to receive(:call).once
box.should_receive(:has_update?).never expect(box).to receive(:has_update?).never
subject.call(env) subject.call(env)
end end
@ -86,9 +86,9 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
context "with a box" do context "with a box" do
it "sets env if no update" do it "sets env if no update" do
box.should_receive(:has_update?).and_return(nil) expect(box).to receive(:has_update?).and_return(nil)
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
subject.call(env) subject.call(env)
@ -116,10 +116,10 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
} }
RAW RAW
box.should_receive(:has_update?).with(machine.config.vm.box_version). expect(box).to receive(:has_update?).with(machine.config.vm.box_version).
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")])
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
subject.call(env) subject.call(env)
@ -127,9 +127,9 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
end end
it "raises error if has_update? errors" do it "raises error if has_update? errors" do
box.should_receive(:has_update?).and_raise(Vagrant::Errors::VagrantError) expect(box).to receive(:has_update?).and_raise(Vagrant::Errors::VagrantError)
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }.to raise_error(Vagrant::Errors::VagrantError) expect { subject.call(env) }.to raise_error(Vagrant::Errors::VagrantError)
end end
@ -137,8 +137,8 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
it "doesn't raise an error if ignore errors is on" do it "doesn't raise an error if ignore errors is on" do
env[:box_outdated_ignore_errors] = true env[:box_outdated_ignore_errors] = true
box.should_receive(:has_update?).and_raise(Vagrant::Errors::VagrantError) expect(box).to receive(:has_update?).and_raise(Vagrant::Errors::VagrantError)
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
expect { subject.call(env) }.to_not raise_error expect { subject.call(env) }.to_not raise_error
end end

View File

@ -24,10 +24,10 @@ describe Vagrant::Action::Builtin::BoxRemove do
env[:box_name] = "foo" env[:box_name] = "foo"
box_collection.should_receive(:find).with( expect(box_collection).to receive(:find).with(
"foo", :virtualbox, "1.0").and_return(box) "foo", :virtualbox, "1.0").and_return(box)
box.should_receive(:destroy!).once expect(box).to receive(:destroy!).once
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
subject.call(env) subject.call(env)
@ -44,10 +44,10 @@ describe Vagrant::Action::Builtin::BoxRemove do
env[:box_name] = "foo" env[:box_name] = "foo"
env[:box_provider] = "virtualbox" env[:box_provider] = "virtualbox"
box_collection.should_receive(:find).with( expect(box_collection).to receive(:find).with(
"foo", :virtualbox, "1.0").and_return(box) "foo", :virtualbox, "1.0").and_return(box)
box.should_receive(:destroy!).once expect(box).to receive(:destroy!).once
app.should_receive(:call).with(env).once expect(app).to receive(:call).with(env).once
subject.call(env) subject.call(env)
@ -57,7 +57,7 @@ describe Vagrant::Action::Builtin::BoxRemove do
it "errors if the box doesn't exist" do it "errors if the box doesn't exist" do
box_collection.stub(all: []) box_collection.stub(all: [])
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxRemoveNotFound) to raise_error(Vagrant::Errors::BoxRemoveNotFound)
@ -69,7 +69,7 @@ describe Vagrant::Action::Builtin::BoxRemove do
box_collection.stub(all: [["foo", "1.0", :virtualbox]]) box_collection.stub(all: [["foo", "1.0", :virtualbox]])
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxRemoveProviderNotFound) to raise_error(Vagrant::Errors::BoxRemoveProviderNotFound)
@ -84,7 +84,7 @@ describe Vagrant::Action::Builtin::BoxRemove do
["foo", "1.0", :vmware], ["foo", "1.0", :vmware],
]) ])
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxRemoveMultiProvider) to raise_error(Vagrant::Errors::BoxRemoveMultiProvider)
@ -100,7 +100,7 @@ describe Vagrant::Action::Builtin::BoxRemove do
["foo", "1.1", :virtualbox], ["foo", "1.1", :virtualbox],
]) ])
app.should_receive(:call).never expect(app).to receive(:call).never
expect { subject.call(env) }. expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxRemoveMultiVersion) to raise_error(Vagrant::Errors::BoxRemoveMultiVersion)

View File

@ -15,7 +15,7 @@ describe Vagrant::Action::Builtin::Call do
received = env[:result] received = env[:result]
end.call({}) end.call({})
received.should == "value" expect(received).to eq("value")
end end
it "should update the original env with any changes" do it "should update the original env with any changes" do
@ -26,7 +26,7 @@ describe Vagrant::Action::Builtin::Call do
builder.use next_step builder.use next_step
end.call(env) end.call(env)
env[:inner].should == true expect(env[:inner]).to eq(true)
end end
it "should call the callable with the original environment" do it "should call the callable with the original environment" do
@ -37,7 +37,7 @@ describe Vagrant::Action::Builtin::Call do
# Nothing. # Nothing.
end.call({ :foo => :bar }) end.call({ :foo => :bar })
received.should == :bar expect(received).to eq(:bar)
end end
it "should call the next builder" do it "should call the next builder" do
@ -49,7 +49,7 @@ describe Vagrant::Action::Builtin::Call do
builder.use next_step builder.use next_step
end.call({}) end.call({})
received.should == "value" expect(received).to eq("value")
end end
it "should call the next builder with the original environment" do it "should call the next builder with the original environment" do
@ -61,7 +61,7 @@ describe Vagrant::Action::Builtin::Call do
builder.use next_step builder.use next_step
end.call({ :foo => :bar }) end.call({ :foo => :bar })
received.should == :bar expect(received).to eq(:bar)
end end
it "should instantiate the callable with the extra args" do it "should instantiate the callable with the extra args" do
@ -81,7 +81,7 @@ describe Vagrant::Action::Builtin::Call do
end end
instance.call(env) instance.call(env)
result.should == :foo expect(result).to eq(:foo)
end end
it "should call the recover method for the sequence in an error" do it "should call the recover method for the sequence in an error" do
@ -131,7 +131,7 @@ describe Vagrant::Action::Builtin::Call do
instance.call(env) instance.call(env)
instance.recover(env) instance.recover(env)
env[:steps].should == [:call_A, :call_B, :recover_B, :recover_A] expect(env[:steps]).to eq([:call_A, :call_B, :recover_B, :recover_A])
end end
it "should recover even if it failed in the callable" do it "should recover even if it failed in the callable" do

View File

@ -7,9 +7,9 @@ describe Vagrant::Action::Builtin::Confirm do
["y", "Y"].each do |valid| ["y", "Y"].each do |valid|
it "should set the result to true if '#{valid}' is given" do it "should set the result to true if '#{valid}' is given" do
env[:ui].should_receive(:ask).with(message).and_return(valid) expect(env[:ui]).to receive(:ask).with(message).and_return(valid)
described_class.new(app, env, message).call(env) described_class.new(app, env, message).call(env)
env[:result].should be expect(env[:result]).to be
end end
end end
@ -17,26 +17,26 @@ describe Vagrant::Action::Builtin::Confirm do
force_key = :tubes force_key = :tubes
env[force_key] = true env[force_key] = true
described_class.new(app, env, message, force_key).call(env) described_class.new(app, env, message, force_key).call(env)
env[:result].should be expect(env[:result]).to be
end end
it "should ask if force is not true" do it "should ask if force is not true" do
force_key = :tubes force_key = :tubes
env[force_key] = false env[force_key] = false
env[:ui].should_receive(:ask).with(message).and_return("nope") expect(env[:ui]).to receive(:ask).with(message).and_return("nope")
described_class.new(app, env, message).call(env) described_class.new(app, env, message).call(env)
env[:result].should_not be expect(env[:result]).not_to be
end end
it "should set result to false if anything else is given" do it "should set result to false if anything else is given" do
env[:ui].should_receive(:ask).with(message).and_return("nope") expect(env[:ui]).to receive(:ask).with(message).and_return("nope")
described_class.new(app, env, message).call(env) described_class.new(app, env, message).call(env)
env[:result].should_not be expect(env[:result]).not_to be
end end
it "should ask multiple times if an allowed set is given and response isn't in that set" do it "should ask multiple times if an allowed set is given and response isn't in that set" do
times = 0 times = 0
env[:ui].stub(:ask) do |arg| allow(env[:ui]).to receive(:ask) do |arg|
expect(arg).to eql(message) expect(arg).to eql(message)
times += 1 times += 1

View File

@ -7,14 +7,14 @@ describe Vagrant::Action::Builtin::EnvSet do
it "should set the new environment" do it "should set the new environment" do
described_class.new(app, env, :foo => :bar).call(env) described_class.new(app, env, :foo => :bar).call(env)
env[:foo].should == :bar expect(env[:foo]).to eq(:bar)
end end
it "should call the next middleware" do it "should call the next middleware" do
callable = lambda { |env| env[:called] = env[:foo] } callable = lambda { |env| env[:called] = env[:foo] }
env[:called].should be_nil expect(env[:called]).to be_nil
described_class.new(callable, env, :foo => :yep).call(env) described_class.new(callable, env, :foo => :yep).call(env)
env[:called].should == :yep expect(env[:called]).to eq(:yep)
end end
end end

View File

@ -5,9 +5,9 @@ describe Vagrant::Action::Builtin::GracefulHalt do
let(:env) { { :machine => machine, :ui => ui } } let(:env) { { :machine => machine, :ui => ui } }
let(:machine) do let(:machine) do
result = double("machine") result = double("machine")
result.stub(:config).and_return(machine_config) allow(result).to receive(:config).and_return(machine_config)
result.stub(:guest).and_return(machine_guest) allow(result).to receive(:guest).and_return(machine_guest)
result.stub(:state).and_return(machine_state) allow(result).to receive(:state).and_return(machine_state)
result result
end end
let(:machine_config) do let(:machine_config) do
@ -20,41 +20,41 @@ describe Vagrant::Action::Builtin::GracefulHalt do
let(:machine_guest) { double("machine_guest") } let(:machine_guest) { double("machine_guest") }
let(:machine_state) do let(:machine_state) do
double("machine_state").tap do |result| double("machine_state").tap do |result|
result.stub(:id).and_return(:unknown) allow(result).to receive(:id).and_return(:unknown)
end end
end end
let(:target_state) { :target } let(:target_state) { :target }
let(:ui) do let(:ui) do
double("ui").tap do |result| double("ui").tap do |result|
result.stub(:output) allow(result).to receive(:output)
end end
end end
it "should do nothing if force is specified" do it "should do nothing if force is specified" do
env[:force_halt] = true env[:force_halt] = true
machine_guest.should_not_receive(:capability) expect(machine_guest).not_to receive(:capability)
described_class.new(app, env, target_state).call(env) described_class.new(app, env, target_state).call(env)
env[:result].should == false expect(env[:result]).to eq(false)
end end
it "should do nothing if there is an invalid source state" do it "should do nothing if there is an invalid source state" do
machine_state.stub(:id).and_return(:invalid_source) allow(machine_state).to receive(:id).and_return(:invalid_source)
machine_guest.should_not_receive(:capability) expect(machine_guest).not_to receive(:capability)
described_class.new(app, env, target_state, :target_source).call(env) described_class.new(app, env, target_state, :target_source).call(env)
env[:result].should == false expect(env[:result]).to eq(false)
end end
it "should gracefully halt and wait for the target state" do it "should gracefully halt and wait for the target state" do
machine_guest.should_receive(:capability).with(:halt).once expect(machine_guest).to receive(:capability).with(:halt).once
machine_state.stub(:id).and_return(target_state) allow(machine_state).to receive(:id).and_return(target_state)
described_class.new(app, env, target_state).call(env) described_class.new(app, env, target_state).call(env)
env[:result].should == true expect(env[:result]).to eq(true)
end end
end end

View File

@ -32,7 +32,7 @@ describe Vagrant::Action::Builtin::HandleBox do
machine.config.vm.box = nil machine.config.vm.box = nil
machine.config.vm.box_url = nil machine.config.vm.box_url = nil
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -40,8 +40,8 @@ describe Vagrant::Action::Builtin::HandleBox do
it "doesn't do anything if a box exists" do it "doesn't do anything if a box exists" do
machine.stub(box: box) machine.stub(box: box)
action_runner.should_receive(:run).never expect(action_runner).to receive(:run).never
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -54,15 +54,15 @@ 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
action_runner.should_receive(:run).with do |action, opts| expect(action_runner).to receive(:run).with { |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)
expect(opts[:box_version]).to eq(machine.config.vm.box_version) expect(opts[:box_version]).to eq(machine.config.vm.box_version)
true true
end }
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -70,15 +70,15 @@ 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]
action_runner.should_receive(:run).with do |action, opts| expect(action_runner).to receive(:run).with { |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])
expect(opts[:box_version]).to eq(machine.config.vm.box_version) expect(opts[:box_version]).to eq(machine.config.vm.box_version)
true true
end }
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end
@ -93,15 +93,15 @@ 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
action_runner.should_receive(:run).with do |action, opts| expect(action_runner).to receive(:run).with { |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)
expect(opts[:box_version]).to eq(machine.config.vm.box_version) expect(opts[:box_version]).to eq(machine.config.vm.box_version)
true true
end }
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end

View File

@ -8,7 +8,7 @@ describe Vagrant::Action::Builtin::IsState do
let(:env) { { :machine => machine } } let(:env) { { :machine => machine } }
let(:machine) do let(:machine) do
double("machine").tap do |machine| double("machine").tap do |machine|
machine.stub(:state).and_return(state) allow(machine).to receive(:state).and_return(state)
end end
end end
@ -20,7 +20,7 @@ describe Vagrant::Action::Builtin::IsState do
subject = described_class.new(app, env, :bar) subject = described_class.new(app, env, :bar)
app.should_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
@ -31,7 +31,7 @@ describe Vagrant::Action::Builtin::IsState do
subject = described_class.new(app, env, :foo) subject = described_class.new(app, env, :foo)
app.should_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
@ -42,7 +42,7 @@ describe Vagrant::Action::Builtin::IsState do
subject = described_class.new(app, env, :foo, invert: true) subject = described_class.new(app, env, :foo, invert: true)
app.should_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

View File

@ -42,7 +42,7 @@ describe Vagrant::Action::Builtin::Lock do
instance = described_class.new(app, env, options) instance = described_class.new(app, env, options)
instance.call(env) instance.call(env)
inner_acquire.should == false expect(inner_acquire).to eq(false)
end end
it "should allow the exception to be a proc" do it "should allow the exception to be a proc" do
@ -51,7 +51,7 @@ describe Vagrant::Action::Builtin::Lock do
File.open(lock_path, "w+") do |f| File.open(lock_path, "w+") do |f|
# Acquire lock # Acquire lock
f.flock(File::LOCK_EX | File::LOCK_NB).should == 0 expect(f.flock(File::LOCK_EX | File::LOCK_NB)).to eq(0)
# Test! # Test!
instance = described_class.new(app, env, options) instance = described_class.new(app, env, options)
@ -71,13 +71,13 @@ describe Vagrant::Action::Builtin::Lock do
instance = described_class.new(app, env, options) instance = described_class.new(app, env, options)
instance.call(env) instance.call(env)
inner_acquire.should == false expect(inner_acquire).to eq(false)
end end
it "should raise an exception if the lock is already held" do it "should raise an exception if the lock is already held" do
File.open(lock_path, "w+") do |f| File.open(lock_path, "w+") do |f|
# Acquire lock # Acquire lock
f.flock(File::LOCK_EX | File::LOCK_NB).should == 0 expect(f.flock(File::LOCK_EX | File::LOCK_NB)).to eq(0)
# Test! # Test!
instance = described_class.new(app, env, options) instance = described_class.new(app, env, options)
@ -93,6 +93,6 @@ describe Vagrant::Action::Builtin::Lock do
outer = described_class.new(inner, env, options) outer = described_class.new(inner, env, options)
outer.call(env) outer.call(env)
called.should == true expect(called).to eq(true)
end end
end end

View File

@ -13,8 +13,8 @@ describe Vagrant::Action::Builtin::Message do
it "outputs the given message" do it "outputs the given message" do
subject = described_class.new(app, env, "foo") subject = described_class.new(app, env, "foo")
ui.should_receive(:output).with("foo") expect(ui).to receive(:output).with("foo")
app.should_receive(:call).with(env) expect(app).to receive(:call).with(env)
subject.call(env) subject.call(env)
end end

View File

@ -13,7 +13,7 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
let(:machine) do let(:machine) do
double("machine").tap do |machine| double("machine").tap do |machine|
machine.stub(:config).and_return(machine_config) allow(machine).to receive(:config).and_return(machine_config)
end end
end end
@ -34,7 +34,7 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
} }
result = subject.default_synced_folder_type(machine, plugins) result = subject.default_synced_folder_type(machine, plugins)
result.should == "good" expect(result).to eq("good")
end end
end end
@ -47,9 +47,9 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
} }
result = subject.impl_opts("foo", env) result = subject.impl_opts("foo", env)
result.length.should == 2 expect(result.length).to eq(2)
result[:foo_bar].should == "baz" expect(result[:foo_bar]).to eq("baz")
result[:foo_baz].should == "bar" expect(result[:foo_baz]).to eq("bar")
end end
end end
@ -79,13 +79,13 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
folders["nfs"] = { type: "nfs" } folders["nfs"] = { type: "nfs" }
result = subject.synced_folders(machine) result = subject.synced_folders(machine)
result.length.should == 2 expect(result.length).to eq(2)
result[:default].should == { expect(result[:default]).to eq({
"another" => folders["another"], "another" => folders["another"],
"foo" => folders["foo"], "foo" => folders["foo"],
"root" => folders["root"], "root" => folders["root"],
} })
result[:nfs].should == { "nfs" => folders["nfs"] } expect(result[:nfs]).to eq({ "nfs" => folders["nfs"] })
end end
it "should error if an explicit type is unusable" do it "should error if an explicit type is unusable" do
@ -101,8 +101,8 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
folders["foo"] = { disabled: true } folders["foo"] = { disabled: true }
result = subject.synced_folders(machine) result = subject.synced_folders(machine)
result.length.should == 1 expect(result.length).to eq(1)
result[:default].length.should == 1 expect(result[:default].length).to eq(1)
end end
it "should scope hash override the settings" do it "should scope hash override the settings" do

View File

@ -7,7 +7,7 @@ describe Vagrant::Action::Builtin::SSHExec do
let(:env) { { :machine => machine } } let(:env) { { :machine => machine } }
let(:machine) do let(:machine) do
result = double("machine") result = double("machine")
result.stub(:ssh_info).and_return(machine_ssh_info) allow(result).to receive(:ssh_info).and_return(machine_ssh_info)
result result
end end
let(:machine_ssh_info) { {} } let(:machine_ssh_info) { {} }
@ -16,13 +16,13 @@ describe Vagrant::Action::Builtin::SSHExec do
before(:each) do before(:each) do
# Stub the methods so that even if we test incorrectly, no side # Stub the methods so that even if we test incorrectly, no side
# effects actually happen. # effects actually happen.
ssh_klass.stub(:check_key_permissions) allow(ssh_klass).to receive(:check_key_permissions)
ssh_klass.stub(:exec) allow(ssh_klass).to receive(:exec)
end end
it "should raise an exception if SSH is not ready" do it "should raise an exception if SSH is not ready" do
not_ready_machine = double("machine") not_ready_machine = double("machine")
not_ready_machine.stub(:ssh_info).and_return(nil) allow(not_ready_machine).to receive(:ssh_info).and_return(nil)
env[:machine] = not_ready_machine env[:machine] = not_ready_machine
expect { described_class.new(app, env).call(env) }. expect { described_class.new(app, env).call(env) }.
@ -33,12 +33,12 @@ describe Vagrant::Action::Builtin::SSHExec do
key_path = "/foo" key_path = "/foo"
machine_ssh_info[:private_key_path] = [key_path] machine_ssh_info[:private_key_path] = [key_path]
ssh_klass.should_receive(:check_key_permissions). expect(ssh_klass).to receive(:check_key_permissions).
with(Pathname.new(key_path)). with(Pathname.new(key_path)).
once. once.
ordered ordered
ssh_klass.should_receive(:exec). expect(ssh_klass).to receive(:exec).
with(machine_ssh_info, nil). with(machine_ssh_info, nil).
once. once.
ordered ordered
@ -49,7 +49,7 @@ describe Vagrant::Action::Builtin::SSHExec do
it "should exec with the options given in `ssh_opts`" do it "should exec with the options given in `ssh_opts`" do
ssh_opts = { :foo => :bar } ssh_opts = { :foo => :bar }
ssh_klass.should_receive(:exec). expect(ssh_klass).to receive(:exec).
with(machine_ssh_info, ssh_opts) with(machine_ssh_info, ssh_opts)
env[:ssh_opts] = ssh_opts env[:ssh_opts] = ssh_opts

View File

@ -10,7 +10,7 @@ describe Vagrant::Action::Builtin::SyncedFolderCleanup do
let(:env) { { :machine => machine, :ui => ui } } let(:env) { { :machine => machine, :ui => ui } }
let(:machine) do let(:machine) do
double("machine").tap do |machine| double("machine").tap do |machine|
machine.stub(:config).and_return(machine_config) allow(machine).to receive(:config).and_return(machine_config)
end end
end end
@ -24,7 +24,7 @@ describe Vagrant::Action::Builtin::SyncedFolderCleanup do
let(:ui) do let(:ui) do
double("ui").tap do |result| double("ui").tap do |result|
result.stub(:info) allow(result).to receive(:info)
end end
end end
@ -127,9 +127,9 @@ describe Vagrant::Action::Builtin::SyncedFolderCleanup do
subject.call(env) subject.call(env)
trackers[0].clean.should be_true expect(trackers[0].clean).to be_true
trackers[1].clean.should be_true expect(trackers[1].clean).to be_true
trackers[2].clean.should be_true expect(trackers[2].clean).to be_true
end end
end end
end end

View File

@ -10,7 +10,7 @@ describe Vagrant::Action::Builtin::SyncedFolders do
let(:env) { { :machine => machine, :ui => ui } } let(:env) { { :machine => machine, :ui => ui } }
let(:machine) do let(:machine) do
double("machine").tap do |machine| double("machine").tap do |machine|
machine.stub(:config).and_return(machine_config) allow(machine).to receive(:config).and_return(machine_config)
end end
end end
@ -24,7 +24,7 @@ describe Vagrant::Action::Builtin::SyncedFolders do
let(:ui) do let(:ui) do
double("ui").tap do |result| double("ui").tap do |result|
result.stub(:info) allow(result).to receive(:info)
end end
end end
@ -57,8 +57,8 @@ describe Vagrant::Action::Builtin::SyncedFolders do
subject.call(env) subject.call(env)
env[:root_path].join("foo").should_not be_directory expect(env[:root_path].join("foo")).not_to be_directory
env[:root_path].join("bar").should be_directory expect(env[:root_path].join("bar")).to be_directory
end end
it "should invoke prepare then enable" do it "should invoke prepare then enable" do
@ -91,7 +91,7 @@ describe Vagrant::Action::Builtin::SyncedFolders do
subject.call(env) subject.call(env)
order.should == [:prepare, :enable] expect(order).to eq([:prepare, :enable])
expect(ids.length).to eq(2) expect(ids.length).to eq(2)
expect(ids[0]).to eq(ids[1]) expect(ids[0]).to eq(ids[1])
end end

View File

@ -5,10 +5,25 @@ require "vagrant/action/hook"
describe Vagrant::Action::Hook do describe Vagrant::Action::Hook do
describe "defaults" do describe "defaults" do
its("after_hooks") { should be_empty } describe '#after_hooks' do
its("before_hooks") { should be_empty } subject { super().after_hooks }
its("append_hooks") { should be_empty } it { should be_empty }
its("prepend_hooks") { should be_empty } end
describe '#before_hooks' do
subject { super().before_hooks }
it { should be_empty }
end
describe '#append_hooks' do
subject { super().append_hooks }
it { should be_empty }
end
describe '#prepend_hooks' do
subject { super().prepend_hooks }
it { should be_empty }
end
end end
describe "before hooks" do describe "before hooks" do
@ -21,11 +36,11 @@ describe Vagrant::Action::Hook do
subject.before(existing, 2) subject.before(existing, 2)
subject.before(existing, 3, :arg, &block) subject.before(existing, 3, :arg, &block)
subject.before_hooks[existing].should == [ expect(subject.before_hooks[existing]).to eq([
[1, [], nil], [1, [], nil],
[2, [], nil], [2, [], nil],
[3, [:arg], block] [3, [:arg], block]
] ])
end end
end end
@ -39,11 +54,11 @@ describe Vagrant::Action::Hook do
subject.after(existing, 2) subject.after(existing, 2)
subject.after(existing, 3, :arg, &block) subject.after(existing, 3, :arg, &block)
subject.after_hooks[existing].should == [ expect(subject.after_hooks[existing]).to eq([
[1, [], nil], [1, [], nil],
[2, [], nil], [2, [], nil],
[3, [:arg], block] [3, [:arg], block]
] ])
end end
end end
@ -55,11 +70,11 @@ describe Vagrant::Action::Hook do
subject.append(2) subject.append(2)
subject.append(3, :arg, &block) subject.append(3, :arg, &block)
subject.append_hooks.should == [ expect(subject.append_hooks).to eq([
[1, [], nil], [1, [], nil],
[2, [], nil], [2, [], nil],
[3, [:arg], block] [3, [:arg], block]
] ])
end end
end end
@ -71,11 +86,11 @@ describe Vagrant::Action::Hook do
subject.prepend(2) subject.prepend(2)
subject.prepend(3, :arg, &block) subject.prepend(3, :arg, &block)
subject.prepend_hooks.should == [ expect(subject.prepend_hooks).to eq([
[1, [], nil], [1, [], nil],
[2, [], nil], [2, [], nil],
[3, [:arg], block] [3, [:arg], block]
] ])
end end
end end
@ -90,12 +105,12 @@ describe Vagrant::Action::Hook do
subject.apply(builder) subject.apply(builder)
builder.stack.should == [ expect(builder.stack).to eq([
["1", [2], nil], ["1", [2], nil],
["2", [], nil], ["2", [], nil],
["8", [], nil], ["8", [], nil],
["9", [], nil] ["9", [], nil]
] ])
end end
it "should not prepend or append if disabled" do it "should not prepend or append if disabled" do
@ -109,12 +124,12 @@ describe Vagrant::Action::Hook do
subject.apply(builder, no_prepend_or_append: true) subject.apply(builder, no_prepend_or_append: true)
builder.stack.should == [ expect(builder.stack).to eq([
["3", [], nil], ["3", [], nil],
["4", [], nil], ["4", [], nil],
["7", [], nil], ["7", [], nil],
["8", [], nil] ["8", [], nil]
] ])
end end
end end
end end

View File

@ -44,7 +44,7 @@ describe Vagrant::Action::Runner do
end end
result = instance.run(callable) result = instance.run(callable)
result[:data].should == "value" expect(result[:data]).to eq("value")
end end
it "should pass options into hash given to callable" do it "should pass options into hash given to callable" do
@ -54,7 +54,7 @@ describe Vagrant::Action::Runner do
end end
instance.run(callable, "data" => "foo") instance.run(callable, "data" => "foo")
result.should == "foo" expect(result).to eq("foo")
end end
it "should pass global options into the hash" do it "should pass global options into the hash" do
@ -65,7 +65,7 @@ describe Vagrant::Action::Runner do
instance = described_class.new("data" => "bar") instance = described_class.new("data" => "bar")
instance.run(callable) instance.run(callable)
result.should == "bar" expect(result).to eq("bar")
end end
it "should yield the block passed to the init method to get lazy loaded globals" do it "should yield the block passed to the init method to get lazy loaded globals" do
@ -76,6 +76,6 @@ describe Vagrant::Action::Runner do
instance = described_class.new { { "data" => "bar" } } instance = described_class.new { { "data" => "bar" } }
instance.run(callable) instance.run(callable)
result.should == "bar" expect(result).to eq("bar")
end end
end end

View File

@ -14,7 +14,7 @@ describe Vagrant::Action::Warden do
instance = described_class.new([appender_proc(1), appender_proc(2)], data) instance = described_class.new([appender_proc(1), appender_proc(2)], data)
instance.call(data) instance.call(data)
data[:data].should == [1, 2] expect(data[:data]).to eq([1, 2])
end end
it "starts a recovery sequence when an exception is raised" do it "starts a recovery sequence when an exception is raised" do
@ -56,10 +56,10 @@ describe Vagrant::Action::Warden do
to raise_error(RuntimeError) to raise_error(RuntimeError)
# Verify the recovery process goes in reverse order # Verify the recovery process goes in reverse order
data[:recover].should == [2, 1] expect(data[:recover]).to eq([2, 1])
# Verify that the error is available in the data # Verify that the error is available in the data
data["vagrant.error"].should be_kind_of(RuntimeError) expect(data["vagrant.error"]).to be_kind_of(RuntimeError)
end end
it "does not do a recovery sequence if SystemExit is raised" do it "does not do a recovery sequence if SystemExit is raised" do
@ -87,6 +87,6 @@ describe Vagrant::Action::Warden do
expect { instance.call(data) }.to raise_error(SystemExit) expect { instance.call(data) }.to raise_error(SystemExit)
# The recover should not have been called # The recover should not have been called
data.has_key?(:recover).should_not be expect(data.has_key?(:recover)).not_to be
end end
end end

View File

@ -13,7 +13,7 @@ describe Vagrant::BatchAction do
double("machine").tap do |m| double("machine").tap do |m|
m.stub(:provider_name => provider_name) m.stub(:provider_name => provider_name)
m.stub(:provider_options => options) m.stub(:provider_options => options)
m.stub(:action) do |action, opts| allow(m).to receive(:action) do |action, opts|
lock.synchronize do lock.synchronize do
called_actions << [m, action, opts] called_actions << [m, action, opts]
end end
@ -30,14 +30,14 @@ describe Vagrant::BatchAction do
subject.action(machine2, "destroy") subject.action(machine2, "destroy")
subject.run subject.run
called_actions.include?([machine, "up", nil]).should be expect(called_actions.include?([machine, "up", nil])).to be
called_actions.include?([machine2, "destroy", nil]).should be expect(called_actions.include?([machine2, "destroy", nil])).to be
end end
it "should handle forks gracefully", :skip_windows do it "should handle forks gracefully", :skip_windows do
# Doesn't need to be tested on Windows since Windows doesn't # Doesn't need to be tested on Windows since Windows doesn't
# support fork(1) # support fork(1)
machine.stub(:action) do |action, opts| allow(machine).to receive(:action) do |action, opts|
pid = fork pid = fork
if !pid if !pid
# Child process # Child process

View File

@ -12,12 +12,12 @@ describe Vagrant::BoxCollection do
subject { described_class.new(environment.boxes_dir) } subject { described_class.new(environment.boxes_dir) }
it "should tell us the directory it is using" do it "should tell us the directory it is using" do
subject.directory.should == environment.boxes_dir expect(subject.directory).to eq(environment.boxes_dir)
end end
describe "#all" do describe "#all" do
it "should return an empty array when no boxes are there" do it "should return an empty array when no boxes are there" do
subject.all.should == [] expect(subject.all).to eq([])
end end
it "should return the boxes and their providers" do it "should return the boxes and their providers" do
@ -29,11 +29,11 @@ describe Vagrant::BoxCollection do
# Verify some output # Verify some output
results = subject.all results = subject.all
results.length.should == 4 expect(results.length).to eq(4)
results.include?(["foo", "1.0", :virtualbox]).should be expect(results.include?(["foo", "1.0", :virtualbox])).to be
results.include?(["foo", "1.0", :vmware]).should be expect(results.include?(["foo", "1.0", :vmware])).to be
results.include?(["bar", "0", :ec2]).should be expect(results.include?(["bar", "0", :ec2])).to be
results.include?(["foo/bar", "1.0", :virtualbox]).should be expect(results.include?(["foo/bar", "1.0", :virtualbox])).to be
end end
it 'does not raise an exception when a file appears in the boxes dir' do it 'does not raise an exception when a file appears in the boxes dir' do
@ -80,11 +80,11 @@ describe Vagrant::BoxCollection do
environment.box3("foo", "0", :virtualbox, environment.box3("foo", "0", :virtualbox,
metadata_url: "foourl") metadata_url: "foourl")
hook.should_receive(:call).with do |name, env| expect(hook).to receive(:call).with { |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
end.and_return(box_urls: ["bar"]) }.and_return(box_urls: ["bar"])
# Actual test # Actual test
result = subject.find("foo", :virtualbox, ">= 0") result = subject.find("foo", :virtualbox, ">= 0")
@ -219,7 +219,7 @@ describe Vagrant::BoxCollection do
# Attempt to add the box with the same name # Attempt to add the box with the same name
box_path = environment.box2_file(prev_box_provider, metadata: { "replaced" => "yes" }) box_path = environment.box2_file(prev_box_provider, metadata: { "replaced" => "yes" })
box = subject.add(box_path, prev_box_name, prev_box_version, force: true) box = subject.add(box_path, prev_box_name, prev_box_version, force: true)
box.metadata["replaced"].should == "yes" expect(box.metadata["replaced"]).to eq("yes")
end end
it "should raise an exception if the box already exists and no provider is given" do it "should raise an exception if the box already exists and no provider is given" do

View File

@ -38,8 +38,15 @@ describe Vagrant::BoxMetadata do
subject { described_class.new(raw) } subject { described_class.new(raw) }
its(:name) { should eq("foo") } describe '#name' do
its(:description) { should eq("bar") } subject { super().name }
it { should eq("foo") }
end
describe '#description' do
subject { super().description }
it { should eq("bar") }
end
context "with poorly formatted JSON" do context "with poorly formatted JSON" do
let(:raw) { let(:raw) {

View File

@ -19,18 +19,21 @@ describe Vagrant::Box do
let(:directory) { environment.box3("foo", "1.0", :virtualbox) } let(:directory) { environment.box3("foo", "1.0", :virtualbox) }
subject { described_class.new(name, provider, version, directory) } subject { described_class.new(name, provider, version, directory) }
its(:metadata_url) { should be_nil } describe '#metadata_url' do
subject { super().metadata_url }
it { should be_nil }
end
it "provides the name" do it "provides the name" do
subject.name.should == name expect(subject.name).to eq(name)
end end
it "provides the provider" do it "provides the provider" do
subject.provider.should == provider expect(subject.provider).to eq(provider)
end end
it "provides the directory" do it "provides the directory" do
subject.directory.should == directory expect(subject.directory).to eq(directory)
end end
it "provides the metadata associated with a box" do it "provides the metadata associated with a box" do
@ -42,7 +45,7 @@ describe Vagrant::Box do
end end
# Verify the metadata # Verify the metadata
subject.metadata.should == data expect(subject.metadata).to eq(data)
end end
context "with a metadata URL" do context "with a metadata URL" do
@ -52,7 +55,10 @@ describe Vagrant::Box do
metadata_url: "foo") metadata_url: "foo")
end end
its(:metadata_url) { should eq("foo") } describe '#metadata_url' do
subject { super().metadata_url }
it { should eq("foo") }
end
end end
context "with a corrupt metadata file" do context "with a corrupt metadata file" do
@ -218,13 +224,13 @@ describe Vagrant::Box do
describe "destroying" do describe "destroying" do
it "should destroy an existing box" do it "should destroy an existing box" do
# Verify that our "box" exists # Verify that our "box" exists
directory.exist?.should be expect(directory.exist?).to be
# Destroy it # Destroy it
subject.destroy!.should be expect(subject.destroy!).to be
# Verify that it is "destroyed" # Verify that it is "destroyed"
directory.exist?.should_not be expect(directory.exist?).not_to be
end end
it "should not error destroying a non-existent box" do it "should not error destroying a non-existent box" do
@ -235,7 +241,7 @@ describe Vagrant::Box do
directory.rmtree directory.rmtree
# Destroy it # Destroy it
box.destroy!.should be expect(box.destroy!).to be
end end
end end
@ -256,7 +262,7 @@ describe Vagrant::Box do
# 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.
new_box = box_collection.add(box_output_path, "foo2", "1.0") new_box = box_collection.add(box_output_path, "foo2", "1.0")
new_box.directory.join("test_file").read.should == test_file_contents expect(new_box.directory.join("test_file").read).to eq(test_file_contents)
end end
end end
@ -265,7 +271,7 @@ describe Vagrant::Box do
a = described_class.new("a", :foo, "1.0", directory) a = described_class.new("a", :foo, "1.0", directory)
b = described_class.new("a", :foo, "1.0", directory) b = described_class.new("a", :foo, "1.0", directory)
a.should == b expect(a).to eq(b)
end end
it "should not be equal if name doesn't match" do it "should not be equal if name doesn't match" do
@ -295,7 +301,7 @@ describe Vagrant::Box do
c = described_class.new("a", :foo2, "1.1", directory) c = described_class.new("a", :foo2, "1.1", directory)
d = described_class.new("b", :foo2, "1.0", directory) d = described_class.new("b", :foo2, "1.0", directory)
[d, c, a, b].sort.should == [a, b, c, d] expect([d, c, a, b].sort).to eq([a, b, c, d])
end end
end end
end end

View File

@ -17,7 +17,7 @@ describe Vagrant::CLI do
describe "#execute" do describe "#execute" do
it "invokes help and exits with 1 if invalid command" do it "invokes help and exits with 1 if invalid command" do
subject = described_class.new(["i-dont-exist"], env) subject = described_class.new(["i-dont-exist"], env)
subject.should_receive(:help).once expect(subject).to receive(:help).once
expect(subject.execute).to eql(1) expect(subject.execute).to eql(1)
end end
@ -25,7 +25,7 @@ describe Vagrant::CLI do
commands[:destroy] = [command_lambda("destroy", 42), {}] commands[:destroy] = [command_lambda("destroy", 42), {}]
subject = described_class.new(["destroy"], env) subject = described_class.new(["destroy"], env)
subject.should_not_receive(:help) expect(subject).not_to receive(:help)
expect(subject.execute).to eql(42) expect(subject.execute).to eql(42)
end end
@ -45,11 +45,11 @@ 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 }]
env.ui.should_receive(:info).with do |message, opts| expect(env.ui).to receive(:info).with { |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
end }
subject.help subject.help
end end

View File

@ -51,9 +51,9 @@ describe Vagrant::Config::Loader do
instance.set(:proc, [[current_version, proc]]) instance.set(:proc, [[current_version, proc]])
config, warnings, errors = instance.load([:proc]) config, warnings, errors = instance.load([:proc])
config[:foo].should == "yep" expect(config[:foo]).to eq("yep")
warnings.should == [] expect(warnings).to eq([])
errors.should == [] expect(errors).to eq([])
end end
end end
@ -73,8 +73,8 @@ describe Vagrant::Config::Loader do
# Run the actual configuration and assert that we get the proper result # Run the actual configuration and assert that we get the proper result
instance.set(:proc, [[current_version, proc]]) instance.set(:proc, [[current_version, proc]])
config, _ = instance.load([:proc]) config, _ = instance.load([:proc])
config[:foo].should == "yep" expect(config[:foo]).to eq("yep")
config[:finalized].should == true expect(config[:finalized]).to eq(true)
end end
end end
@ -96,8 +96,8 @@ describe Vagrant::Config::Loader do
proc = lambda { |config| config[:foo] = "yep" } proc = lambda { |config| config[:foo] = "yep" }
instance.set(:proc, [["1", proc]]) instance.set(:proc, [["1", proc]])
config, _ = instance.load([:proc]) config, _ = instance.load([:proc])
config[:foo].should == "yep" expect(config[:foo]).to eq("yep")
config[:v2].should == true expect(config[:v2]).to eq(true)
end end
it "should keep track of warnings and errors" do it "should keep track of warnings and errors" do
@ -117,10 +117,10 @@ describe Vagrant::Config::Loader do
proc = lambda { |config| config[:foo] = "yep" } proc = lambda { |config| config[:foo] = "yep" }
instance.set(:proc, [["1", proc]]) instance.set(:proc, [["1", proc]])
config, warnings, errors = instance.load([:proc]) config, warnings, errors = instance.load([:proc])
config[:foo].should == "yep" expect(config[:foo]).to eq("yep")
config[:v2].should == true expect(config[:v2]).to eq(true)
warnings.should == ["foo!"] expect(warnings).to eq(["foo!"])
errors.should == ["bar!"] expect(errors).to eq(["bar!"])
end end
end end
@ -138,10 +138,10 @@ describe Vagrant::Config::Loader do
result, _ = instance.load([:proc]) result, _ = instance.load([:proc])
# Verify the config result # Verify the config result
result[:foo].should == "yep" expect(result[:foo]).to eq("yep")
# Verify the count is only one # Verify the count is only one
count.should == 1 expect(count).to eq(1)
end end
end end
@ -154,7 +154,7 @@ describe Vagrant::Config::Loader do
5.times { instance.set(:file, file) } 5.times { instance.set(:file, file) }
5.times { instance.load([:file]) } 5.times { instance.load([:file]) }
$_config_data.should == 1 expect($_config_data).to eq(1)
end end
it "should not clear the cache if setting to the same value multiple times" do it "should not clear the cache if setting to the same value multiple times" do
@ -168,7 +168,7 @@ describe Vagrant::Config::Loader do
instance.set(:proc, file) instance.set(:proc, file)
5.times { instance.load([:proc]) } 5.times { instance.load([:proc]) }
$_config_data.should == 1 expect($_config_data).to eq(1)
end end
it "should raise proper error if there is a syntax error in a Vagrantfile" do it "should raise proper error if there is a syntax error in a Vagrantfile" do

View File

@ -7,14 +7,14 @@ describe Vagrant::Config::V1::DummyConfig do
end end
it "should allow method calls that return more DummyConfigs" do it "should allow method calls that return more DummyConfigs" do
subject.foo.should be_kind_of(described_class) expect(subject.foo).to be_kind_of(described_class)
end end
it "should allow hash access" do it "should allow hash access" do
expect { subject[:foo] }. expect { subject[:foo] }.
to_not raise_error to_not raise_error
subject[:foo].should be_kind_of(described_class) expect(subject[:foo]).to be_kind_of(described_class)
end end
it "should allow setting hash values" do it "should allow setting hash values" do

View File

@ -13,7 +13,7 @@ describe Vagrant::Config::V1::Loader do
describe "empty" do describe "empty" do
it "returns an empty configuration object" do it "returns an empty configuration object" do
result = described_class.init result = described_class.init
result.should be_kind_of(Vagrant::Config::V1::Root) expect(result).to be_kind_of(Vagrant::Config::V1::Root)
end end
it "returns an object with all configuration keys loaded if V1" do it "returns an object with all configuration keys loaded if V1" do
@ -28,8 +28,8 @@ describe Vagrant::Config::V1::Loader do
# Test that we have all keys # Test that we have all keys
result = described_class.init result = described_class.init
result.foo.should be_kind_of(OpenStruct) expect(result.foo).to be_kind_of(OpenStruct)
result.bar.should be_kind_of(OpenStruct) expect(result.bar).to be_kind_of(OpenStruct)
end end
it "returns only upgradable config objects if not V1" do it "returns only upgradable config objects if not V1" do
@ -44,7 +44,7 @@ describe Vagrant::Config::V1::Loader do
# Test that we have all keys # Test that we have all keys
result = described_class.init result = described_class.init
result.bar.should be_kind_of(OpenStruct) expect(result.bar).to be_kind_of(OpenStruct)
end end
end end
@ -70,11 +70,11 @@ describe Vagrant::Config::V1::Loader do
# Test that it works properly # Test that it works properly
config = described_class.load(config_proc) config = described_class.load(config_proc)
config.foo.bar.should == "value" expect(config.foo.bar).to eq("value")
# Finalize it # Finalize it
described_class.finalize(config) described_class.finalize(config)
config.foo.bar.should == "finalized" expect(config.foo.bar).to eq("finalized")
end end
end end
@ -92,7 +92,7 @@ describe Vagrant::Config::V1::Loader do
# Test that it works properly # Test that it works properly
config = described_class.load(config_proc) config = described_class.load(config_proc)
config.foo.bar.should == "value" expect(config.foo.bar).to eq("value")
end end
end end
@ -101,8 +101,8 @@ describe Vagrant::Config::V1::Loader do
old = Vagrant::Config::V1::Root.new({ :foo => Object }) old = Vagrant::Config::V1::Root.new({ :foo => Object })
new = Vagrant::Config::V1::Root.new({ :bar => Object }) new = Vagrant::Config::V1::Root.new({ :bar => Object })
result = described_class.merge(old, new) result = described_class.merge(old, new)
result.foo.should be_kind_of(Object) expect(result.foo).to be_kind_of(Object)
result.bar.should be_kind_of(Object) expect(result.bar).to be_kind_of(Object)
end end
it "should merge instantiated objects" do it "should merge instantiated objects" do
@ -117,8 +117,8 @@ describe Vagrant::Config::V1::Loader do
new.bar.value = "new" new.bar.value = "new"
result = described_class.merge(old, new) result = described_class.merge(old, new)
result.foo.value.should == "old" expect(result.foo.value).to eq("old")
result.bar.value.should == "new" expect(result.bar.value).to eq("new")
end end
it "should merge conflicting classes by calling `merge`" do it "should merge conflicting classes by calling `merge`" do
@ -139,7 +139,7 @@ describe Vagrant::Config::V1::Loader do
new.foo.value = 15 new.foo.value = 15
result = described_class.merge(old, new) result = described_class.merge(old, new)
result.foo.value.should == 25 expect(result.foo.value).to eq(25)
end end
end end
end end

View File

@ -9,23 +9,23 @@ describe Vagrant::Config::V1::Root do
instance = described_class.new(map) instance = described_class.new(map)
foo = instance.foo foo = instance.foo
foo.should be_kind_of(foo_class) expect(foo).to be_kind_of(foo_class)
instance.foo.should eql(foo) expect(instance.foo).to eql(foo)
end end
it "can be created with initial state" do it "can be created with initial state" do
instance = described_class.new({}, { :foo => "bar" }) instance = described_class.new({}, { :foo => "bar" })
instance.foo.should == "bar" expect(instance.foo).to eq("bar")
end end
it "should return internal state" do it "should return internal state" do
map = { "foo" => Object, "bar" => Object } map = { "foo" => Object, "bar" => Object }
instance = described_class.new(map) instance = described_class.new(map)
instance.__internal_state.should == { expect(instance.__internal_state).to eq({
"config_map" => map, "config_map" => map,
"keys" => {}, "keys" => {},
"missing_key_calls" => Set.new "missing_key_calls" => Set.new
} })
end end
it "should record missing key calls" do it "should record missing key calls" do
@ -33,8 +33,8 @@ describe Vagrant::Config::V1::Root do
instance.foo.bar = false instance.foo.bar = false
keys = instance.__internal_state["missing_key_calls"] keys = instance.__internal_state["missing_key_calls"]
keys.should be_kind_of(Set) expect(keys).to be_kind_of(Set)
keys.length.should == 1 expect(keys.length).to eq(1)
keys.include?("foo").should be expect(keys.include?("foo")).to be
end end
end end

View File

@ -7,14 +7,14 @@ describe Vagrant::Config::V2::DummyConfig do
end end
it "should allow method calls that return more DummyConfigs" do it "should allow method calls that return more DummyConfigs" do
subject.foo.should be_kind_of(described_class) expect(subject.foo).to be_kind_of(described_class)
end end
it "should allow hash access" do it "should allow hash access" do
expect { subject[:foo] }. expect { subject[:foo] }.
to_not raise_error to_not raise_error
subject[:foo].should be_kind_of(described_class) expect(subject[:foo]).to be_kind_of(described_class)
end end
it "should allow setting hash values" do it "should allow setting hash values" do

View File

@ -13,7 +13,7 @@ describe Vagrant::Config::V2::Loader do
describe "empty" do describe "empty" do
it "returns an empty configuration object" do it "returns an empty configuration object" do
result = described_class.init result = described_class.init
result.should be_kind_of(Vagrant::Config::V2::Root) expect(result).to be_kind_of(Vagrant::Config::V2::Root)
end end
end end
@ -39,11 +39,11 @@ describe Vagrant::Config::V2::Loader do
# Test that it works properly # Test that it works properly
config = described_class.load(config_proc) config = described_class.load(config_proc)
config.foo.bar.should == "value" expect(config.foo.bar).to eq("value")
# Finalize it # Finalize it
described_class.finalize(config) described_class.finalize(config)
config.foo.bar.should == "finalized" expect(config.foo.bar).to eq("finalized")
end end
end end
@ -61,7 +61,7 @@ describe Vagrant::Config::V2::Loader do
# Test that it works properly # Test that it works properly
config = described_class.load(config_proc) config = described_class.load(config_proc)
config.foo.bar.should == "value" expect(config.foo.bar).to eq("value")
end end
end end
@ -70,8 +70,8 @@ describe Vagrant::Config::V2::Loader do
old = Vagrant::Config::V2::Root.new({ :foo => Object }) old = Vagrant::Config::V2::Root.new({ :foo => Object })
new = Vagrant::Config::V2::Root.new({ :bar => Object }) new = Vagrant::Config::V2::Root.new({ :bar => Object })
result = described_class.merge(old, new) result = described_class.merge(old, new)
result.foo.should be_kind_of(Object) expect(result.foo).to be_kind_of(Object)
result.bar.should be_kind_of(Object) expect(result.bar).to be_kind_of(Object)
end end
it "should merge instantiated objects" do it "should merge instantiated objects" do
@ -86,8 +86,8 @@ describe Vagrant::Config::V2::Loader do
new.bar.value = "new" new.bar.value = "new"
result = described_class.merge(old, new) result = described_class.merge(old, new)
result.foo.value.should == "old" expect(result.foo.value).to eq("old")
result.bar.value.should == "new" expect(result.bar.value).to eq("new")
end end
it "should merge conflicting classes by calling `merge`" do it "should merge conflicting classes by calling `merge`" do
@ -108,7 +108,7 @@ describe Vagrant::Config::V2::Loader do
new.foo.value = 15 new.foo.value = 15
result = described_class.merge(old, new) result = described_class.merge(old, new)
result.foo.value.should == 25 expect(result.foo.value).to eq(25)
end end
end end
@ -143,9 +143,9 @@ describe Vagrant::Config::V2::Loader do
old.foo.value = 5 old.foo.value = 5
data = described_class.upgrade(old) data = described_class.upgrade(old)
data[0].foo.value.should == 10 expect(data[0].foo.value).to eq(10)
data[1].should == ["foo"] expect(data[1]).to eq(["foo"])
data[2].should == ["bar"] expect(data[2]).to eq(["bar"])
end end
end end
end end

View File

@ -11,14 +11,14 @@ describe Vagrant::Config::V2::Root do
instance = described_class.new(map) instance = described_class.new(map)
foo = instance.foo foo = instance.foo
foo.should be_kind_of(foo_class) expect(foo).to be_kind_of(foo_class)
instance.foo.should eql(foo) expect(instance.foo).to eql(foo)
end end
it "record a missing key call if invalid key used" do it "record a missing key call if invalid key used" do
instance = described_class.new({}) instance = described_class.new({})
expect { instance.foo }.to_not raise_error expect { instance.foo }.to_not raise_error
instance.__internal_state["missing_key_calls"].include?("foo").should be expect(instance.__internal_state["missing_key_calls"].include?("foo")).to be
end end
it "returns a dummy config for a missing key" do it "returns a dummy config for a missing key" do
@ -28,17 +28,17 @@ describe Vagrant::Config::V2::Root do
it "can be created with initial state" do it "can be created with initial state" do
instance = described_class.new({}, { :foo => "bar" }) instance = described_class.new({}, { :foo => "bar" })
instance.foo.should == "bar" expect(instance.foo).to eq("bar")
end end
it "should return internal state" do it "should return internal state" do
map = { "foo" => Object, "bar" => Object } map = { "foo" => Object, "bar" => Object }
instance = described_class.new(map) instance = described_class.new(map)
instance.__internal_state.should == { expect(instance.__internal_state).to eq({
"config_map" => map, "config_map" => map,
"keys" => {}, "keys" => {},
"missing_key_calls" => Set.new "missing_key_calls" => Set.new
} })
end end
describe "#finalize!" do describe "#finalize!" do
@ -55,14 +55,14 @@ describe Vagrant::Config::V2::Root do
instance = described_class.new(map) instance = described_class.new(map)
instance.finalize! instance.finalize!
instance.foo.foo.should == "SET" expect(instance.foo.foo).to eq("SET")
end end
it "should call #_finalize!" do it "should call #_finalize!" do
klass = Class.new(Vagrant.plugin("2", "config")) klass = Class.new(Vagrant.plugin("2", "config"))
klass.any_instance.should_receive(:finalize!) expect_any_instance_of(klass).to receive(:finalize!)
klass.any_instance.should_receive(:_finalize!) expect_any_instance_of(klass).to receive(:_finalize!)
map = { foo: klass } map = { foo: klass }
instance = described_class.new(map) instance = described_class.new(map)
@ -77,7 +77,7 @@ describe Vagrant::Config::V2::Root do
end end
it "should return nil if valid" do it "should return nil if valid" do
instance.validate({}).should == {} expect(instance.validate({})).to eq({})
end end
it "should return errors if invalid" do it "should return errors if invalid" do
@ -88,7 +88,7 @@ describe Vagrant::Config::V2::Root do
env["errors"] env["errors"]
end end
instance.validate(env).should == errors expect(instance.validate(env)).to eq(errors)
end end
it "should merge errors via array concat if matching keys" do it "should merge errors via array concat if matching keys" do
@ -109,7 +109,7 @@ describe Vagrant::Config::V2::Root do
"bar" => ["bar"] "bar" => ["bar"]
} }
instance.validate(env).should == expected_errors expect(instance.validate(env)).to eq(expected_errors)
end end
it "shouldn't count empty keys" do it "shouldn't count empty keys" do
@ -120,7 +120,7 @@ describe Vagrant::Config::V2::Root do
env["errors"] env["errors"]
end end
instance.validate(env).should == {} expect(instance.validate(env)).to eq({})
end end
end end
end end

View File

@ -15,7 +15,7 @@ describe Vagrant::Config::V2::Util do
} }
result = described_class.merge_errors(first, second) result = described_class.merge_errors(first, second)
result.should == expected expect(result).to eq(expected)
end end
end end
end end

View File

@ -20,14 +20,14 @@ describe Vagrant::Config do
end end
end end
procs.should be_kind_of(Array) expect(procs).to be_kind_of(Array)
procs.length.should == 2 expect(procs.length).to eq(2)
procs[0][0].should == "1" expect(procs[0][0]).to eq("1")
procs[1][0].should == "2" expect(procs[1][0]).to eq("2")
# Verify the proper procs were captured # Verify the proper procs were captured
receiver.should_receive(:one).once.ordered expect(receiver).to receive(:one).once.ordered
receiver.should_receive(:two).once.ordered expect(receiver).to receive(:two).once.ordered
procs[0][1].call procs[0][1].call
procs[1][1].call procs[1][1].call
end end
@ -45,14 +45,14 @@ describe Vagrant::Config do
end end
end end
procs.should be_kind_of(Array) expect(procs).to be_kind_of(Array)
procs.length.should == 2 expect(procs.length).to eq(2)
procs[0][0].should == "1" expect(procs[0][0]).to eq("1")
procs[1][0].should == "2" expect(procs[1][0]).to eq("2")
# Verify the proper procs were captured # Verify the proper procs were captured
receiver.should_receive(:one).once.ordered expect(receiver).to receive(:one).once.ordered
receiver.should_receive(:two).once.ordered expect(receiver).to receive(:two).once.ordered
procs[0][1].call procs[0][1].call
procs[1][1].call procs[1][1].call
end end
@ -67,12 +67,12 @@ describe Vagrant::Config do
end end
# Verify the structure of the result # Verify the structure of the result
procs.should be_kind_of(Array) expect(procs).to be_kind_of(Array)
procs.length.should == 1 expect(procs.length).to eq(1)
# Verify that the proper proc was captured # Verify that the proper proc was captured
receiver.should_receive(:hello!).once expect(receiver).to receive(:hello!).once
procs[0][0].should == "1" expect(procs[0][0]).to eq("1")
procs[0][1].call procs[0][1].call
end end
@ -83,9 +83,9 @@ describe Vagrant::Config do
end end
# Verify the structure of the result # Verify the structure of the result
procs.should be_kind_of(Array) expect(procs).to be_kind_of(Array)
procs.length.should == 2 expect(procs.length).to eq(2)
procs[0][0].should == "1" expect(procs[0][0]).to eq("1")
procs[1][0].should == "2" expect(procs[1][0]).to eq("2")
end end
end end

View File

@ -29,7 +29,7 @@ describe Vagrant::Environment do
it "is set to the home path given" do it "is set to the home path given" do
Dir.mktmpdir do |dir| Dir.mktmpdir do |dir|
instance = described_class.new(:home_path => dir) instance = described_class.new(:home_path => dir)
instance.home_path.should == Pathname.new(dir) expect(instance.home_path).to eq(Pathname.new(dir))
end end
end end
@ -39,7 +39,7 @@ describe Vagrant::Environment do
described_class.new described_class.new
end end
instance.home_path.should == Pathname.new(dir) expect(instance.home_path).to eq(Pathname.new(dir))
end end
end end
@ -111,9 +111,9 @@ describe Vagrant::Environment do
Vagrant::Environment.any_instance.stub(boxes: double("boxes")) Vagrant::Environment.any_instance.stub(boxes: double("boxes"))
collection = double("collection") collection = double("collection")
Vagrant::BoxCollection.should_receive(:new).with( expect(Vagrant::BoxCollection).to receive(:new).with(
env.homedir.join("boxes"), anything).and_return(collection) env.homedir.join("boxes"), anything).and_return(collection)
collection.should_receive(:upgrade_v1_1_v1_5).once expect(collection).to receive(:upgrade_v1_1_v1_5).once
subject subject
end end
end end
@ -262,10 +262,10 @@ VF
# Verify that we can get the machine # Verify that we can get the machine
env = isolated_env.create_vagrant_env env = isolated_env.create_vagrant_env
machine = env.machine(:foo, :foo) machine = env.machine(:foo, :foo)
machine.should be_kind_of(Vagrant::Machine) expect(machine).to be_kind_of(Vagrant::Machine)
machine.name.should == :foo expect(machine.name).to eq(:foo)
machine.provider.should be_kind_of(foo_provider) expect(machine.provider).to be_kind_of(foo_provider)
machine.provider_config.should be_nil expect(machine.provider_config).to be_nil
end end
it "should return a machine object with the machine configuration" do it "should return a machine object with the machine configuration" do
@ -295,10 +295,10 @@ VF
# Verify that we can get the machine # Verify that we can get the machine
env = isolated_env.create_vagrant_env env = isolated_env.create_vagrant_env
machine = env.machine(:foo, :foo) machine = env.machine(:foo, :foo)
machine.should be_kind_of(Vagrant::Machine) expect(machine).to be_kind_of(Vagrant::Machine)
machine.name.should == :foo expect(machine.name).to eq(:foo)
machine.provider.should be_kind_of(foo_provider) expect(machine.provider).to be_kind_of(foo_provider)
machine.provider_config.value.should == 100 expect(machine.provider_config.value).to eq(100)
end end
it "should cache the machine objects by name and provider" do it "should cache the machine objects by name and provider" do
@ -325,10 +325,10 @@ VF
vm1_bar = env.machine(:vm1, :bar) vm1_bar = env.machine(:vm1, :bar)
vm2_foo = env.machine(:vm2, :foo) vm2_foo = env.machine(:vm2, :foo)
vm1_foo.should eql(env.machine(:vm1, :foo)) expect(vm1_foo).to eql(env.machine(:vm1, :foo))
vm1_bar.should eql(env.machine(:vm1, :bar)) expect(vm1_bar).to eql(env.machine(:vm1, :bar))
vm1_foo.should_not eql(vm1_bar) expect(vm1_foo).not_to eql(vm1_bar)
vm2_foo.should eql(env.machine(:vm2, :foo)) expect(vm2_foo).to eql(env.machine(:vm2, :foo))
end end
it "should load a machine without a box" do it "should load a machine without a box" do
@ -344,7 +344,7 @@ VF
env = environment.create_vagrant_env env = environment.create_vagrant_env
machine = env.machine(:default, :foo) machine = env.machine(:default, :foo)
machine.box.should be_nil expect(machine.box).to be_nil
end end
it "should load the machine configuration" do it "should load the machine configuration" do
@ -367,8 +367,8 @@ VF
env = environment.create_vagrant_env env = environment.create_vagrant_env
machine = env.machine(:vm1, :foo) machine = env.machine(:vm1, :foo)
machine.config.ssh.port.should == 100 expect(machine.config.ssh.port).to eq(100)
machine.config.vm.box.should == "base" expect(machine.config.vm.box).to eq("base")
end end
it "should load the box configuration for a box" do it "should load the box configuration for a box" do
@ -390,7 +390,7 @@ VF
env = environment.create_vagrant_env env = environment.create_vagrant_env
machine = env.machine(:default, :foo) machine = env.machine(:default, :foo)
machine.config.ssh.port.should == 100 expect(machine.config.ssh.port).to eq(100)
end end
it "should load the box configuration for a box and custom Vagrantfile name" do it "should load the box configuration for a box and custom Vagrantfile name" do
@ -415,7 +415,7 @@ VF
end end
machine = env.machine(:default, :foo) machine = env.machine(:default, :foo)
machine.config.ssh.port.should == 100 expect(machine.config.ssh.port).to eq(100)
end end
it "should load the box configuration for other formats for a box" do it "should load the box configuration for other formats for a box" do
@ -437,7 +437,7 @@ VF
env = environment.create_vagrant_env env = environment.create_vagrant_env
machine = env.machine(:default, :foo) machine = env.machine(:default, :foo)
machine.config.ssh.port.should == 100 expect(machine.config.ssh.port).to eq(100)
end end
it "prefer sooner formats when multiple box formats are available" do it "prefer sooner formats when multiple box formats are available" do
@ -465,7 +465,7 @@ VF
env = environment.create_vagrant_env env = environment.create_vagrant_env
machine = env.machine(:default, :foo) machine = env.machine(:default, :foo)
machine.config.ssh.port.should == 100 expect(machine.config.ssh.port).to eq(100)
end end
it "should load the proper version of a box" do it "should load the proper version of a box" do
@ -494,7 +494,7 @@ VF
env = environment.create_vagrant_env env = environment.create_vagrant_env
machine = env.machine(:default, :foo) machine = env.machine(:default, :foo)
machine.config.ssh.port.should == 200 expect(machine.config.ssh.port).to eq(200)
end end
it "should load the provider override if set" do it "should load the provider override if set" do
@ -516,8 +516,8 @@ VF
env = isolated_env.create_vagrant_env env = isolated_env.create_vagrant_env
foo_vm = env.machine(:default, :foo) foo_vm = env.machine(:default, :foo)
bar_vm = env.machine(:default, :bar) bar_vm = env.machine(:default, :bar)
foo_vm.config.vm.box.should == "bar" expect(foo_vm.config.vm.box).to eq("bar")
bar_vm.config.vm.box.should == "foo" expect(bar_vm.config.vm.box).to eq("foo")
end end
it "should reload the cache if refresh is set" do it "should reload the cache if refresh is set" do
@ -540,8 +540,8 @@ VF
vm2 = env.machine(:default, :foo, true) vm2 = env.machine(:default, :foo, true)
vm3 = env.machine(:default, :foo) vm3 = env.machine(:default, :foo)
vm1.should_not eql(vm2) expect(vm1).not_to eql(vm2)
vm2.should eql(vm3) expect(vm2).to eql(vm3)
end end
it "should raise an error if the VM is not found" do it "should raise an error if the VM is not found" do
@ -558,9 +558,9 @@ VF
describe "active machines" do describe "active machines" do
it "should be empty if the machines folder doesn't exist" do it "should be empty if the machines folder doesn't exist" do
folder = instance.local_data_path.join("machines") folder = instance.local_data_path.join("machines")
folder.should_not be_exist expect(folder).not_to be_exist
instance.active_machines.should be_empty expect(instance.active_machines).to be_empty
end end
it "should return the name and provider of active machines" do it "should return the name and provider of active machines" do
@ -575,22 +575,22 @@ VF
machine_bar = machines.join("bar/virtualbox") machine_bar = machines.join("bar/virtualbox")
machine_bar.mkpath machine_bar.mkpath
instance.active_machines.should == [[:foo, :virtualbox]] expect(instance.active_machines).to eq([[:foo, :virtualbox]])
end end
end end
describe "batching" do describe "batching" do
let(:batch) do let(:batch) do
double("batch") do |b| double("batch") do |b|
b.stub(:run) allow(b).to receive(:run)
end end
end end
context "without the disabling env var" do context "without the disabling env var" do
it "should run without disabling parallelization" do it "should run without disabling parallelization" do
with_temp_env("VAGRANT_NO_PARALLEL" => nil) do with_temp_env("VAGRANT_NO_PARALLEL" => nil) do
Vagrant::BatchAction.should_receive(:new).with(true).and_return(batch) expect(Vagrant::BatchAction).to receive(:new).with(true).and_return(batch)
batch.should_receive(:run) expect(batch).to receive(:run)
instance.batch {} instance.batch {}
end end
@ -598,8 +598,8 @@ VF
it "should run with disabling parallelization if explicit" do it "should run with disabling parallelization if explicit" do
with_temp_env("VAGRANT_NO_PARALLEL" => nil) do with_temp_env("VAGRANT_NO_PARALLEL" => nil) do
Vagrant::BatchAction.should_receive(:new).with(false).and_return(batch) expect(Vagrant::BatchAction).to receive(:new).with(false).and_return(batch)
batch.should_receive(:run) expect(batch).to receive(:run)
instance.batch(false) {} instance.batch(false) {}
end end
@ -609,8 +609,8 @@ VF
context "with the disabling env var" do context "with the disabling env var" do
it "should run with disabling parallelization" do it "should run with disabling parallelization" do
with_temp_env("VAGRANT_NO_PARALLEL" => "yes") do with_temp_env("VAGRANT_NO_PARALLEL" => "yes") do
Vagrant::BatchAction.should_receive(:new).with(false).and_return(batch) expect(Vagrant::BatchAction).to receive(:new).with(false).and_return(batch)
batch.should_receive(:run) expect(batch).to receive(:run)
instance.batch {} instance.batch {}
end end
@ -623,7 +623,7 @@ VF
Dir.mktmpdir do |temp_dir| Dir.mktmpdir do |temp_dir|
Dir.chdir(temp_dir) do Dir.chdir(temp_dir) do
with_temp_env("VAGRANT_CWD" => nil) do with_temp_env("VAGRANT_CWD" => nil) do
described_class.new.cwd.should == Pathname.new(Dir.pwd) expect(described_class.new.cwd).to eq(Pathname.new(Dir.pwd))
end end
end end
end end
@ -632,7 +632,7 @@ VF
it "is set to the cwd given" do it "is set to the cwd given" do
Dir.mktmpdir do |directory| Dir.mktmpdir do |directory|
instance = described_class.new(:cwd => directory) instance = described_class.new(:cwd => directory)
instance.cwd.should == Pathname.new(directory) expect(instance.cwd).to eq(Pathname.new(directory))
end end
end end
@ -642,7 +642,7 @@ VF
described_class.new described_class.new
end end
instance.cwd.should == Pathname.new(directory) expect(instance.cwd).to eq(Pathname.new(directory))
end end
end end
@ -655,13 +655,13 @@ VF
describe "default provider" do describe "default provider" do
it "is virtualbox without any environmental variable" do it "is virtualbox without any environmental variable" do
with_temp_env("VAGRANT_DEFAULT_PROVIDER" => nil) do with_temp_env("VAGRANT_DEFAULT_PROVIDER" => nil) do
subject.default_provider.should == :virtualbox expect(subject.default_provider).to eq(:virtualbox)
end end
end end
it "is whatever the environmental variable is if set" do it "is whatever the environmental variable is if set" do
with_temp_env("VAGRANT_DEFAULT_PROVIDER" => "foo") do with_temp_env("VAGRANT_DEFAULT_PROVIDER" => "foo") do
subject.default_provider.should == :foo expect(subject.default_provider).to eq(:foo)
end end
end end
end end
@ -669,18 +669,18 @@ VF
describe "local data path" do describe "local data path" do
it "is set to the proper default" do it "is set to the proper default" do
default = instance.root_path.join(described_class::DEFAULT_LOCAL_DATA) default = instance.root_path.join(described_class::DEFAULT_LOCAL_DATA)
instance.local_data_path.should == default expect(instance.local_data_path).to eq(default)
end end
it "is expanded relative to the cwd" do it "is expanded relative to the cwd" do
instance = described_class.new(:local_data_path => "foo") instance = described_class.new(:local_data_path => "foo")
instance.local_data_path.should == instance.cwd.join("foo") expect(instance.local_data_path).to eq(instance.cwd.join("foo"))
end end
it "is set to the given value" do it "is set to the given value" do
Dir.mktmpdir do |dir| Dir.mktmpdir do |dir|
instance = described_class.new(:local_data_path => dir) instance = described_class.new(:local_data_path => dir)
instance.local_data_path.to_s.should == dir expect(instance.local_data_path.to_s).to eq(dir)
end end
end end
@ -701,7 +701,7 @@ VF
end end
expect { instance }.to_not raise_error expect { instance }.to_not raise_error
Pathname.new(local_data_path).should be_directory expect(Pathname.new(local_data_path)).to be_directory
end end
it "should upgrade all active VMs" do it "should upgrade all active VMs" do
@ -720,12 +720,12 @@ VF
local_data_pathname = Pathname.new(local_data_path) local_data_pathname = Pathname.new(local_data_path)
foo_id_file = local_data_pathname.join("machines/foo/virtualbox/id") foo_id_file = local_data_pathname.join("machines/foo/virtualbox/id")
foo_id_file.should be_file expect(foo_id_file).to be_file
foo_id_file.read.should == "foo_id" expect(foo_id_file.read).to eq("foo_id")
bar_id_file = local_data_pathname.join("machines/bar/virtualbox/id") bar_id_file = local_data_pathname.join("machines/bar/virtualbox/id")
bar_id_file.should be_file expect(bar_id_file).to be_file
bar_id_file.read.should == "bar_id" expect(bar_id_file.read).to eq("bar_id")
end end
it "should raise an error if invalid JSON" do it "should raise an error if invalid JSON" do
@ -745,18 +745,18 @@ VF
instance = described_class.new(:home_path => env.homedir) instance = described_class.new(:home_path => env.homedir)
pk = env.homedir.join("insecure_private_key") pk = env.homedir.join("insecure_private_key")
pk.should be_exist expect(pk).to be_exist
if !Vagrant::Util::Platform.windows? if !Vagrant::Util::Platform.windows?
Vagrant::Util::FileMode.from_octal(pk.stat.mode).should == "600" expect(Vagrant::Util::FileMode.from_octal(pk.stat.mode)).to eq("600")
end end
end end
end end
it "has a box collection pointed to the proper directory" do it "has a box collection pointed to the proper directory" do
collection = instance.boxes collection = instance.boxes
collection.should be_kind_of(Vagrant::BoxCollection) expect(collection).to be_kind_of(Vagrant::BoxCollection)
collection.directory.should == instance.boxes_path expect(collection.directory).to eq(instance.boxes_path)
# Reach into some internal state here but not sure how else # Reach into some internal state here but not sure how else
# to test this at the moment. # to test this at the moment.
@ -766,7 +766,7 @@ VF
describe "action runner" do describe "action runner" do
it "has an action runner" do it "has an action runner" do
instance.action_runner.should be_kind_of(Vagrant::Action::Runner) expect(instance.action_runner).to be_kind_of(Vagrant::Action::Runner)
end end
it "has a `ui` in the globals" do it "has a `ui` in the globals" do
@ -774,7 +774,7 @@ VF
callable = lambda { |env| result = env[:ui] } callable = lambda { |env| result = env[:ui] }
instance.action_runner.run(callable) instance.action_runner.run(callable)
result.should eql(instance.ui) expect(result).to eql(instance.ui)
end end
end end
@ -782,39 +782,39 @@ 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
instance.action_runner.should_receive(:run).with do |callable, env| expect(instance.action_runner).to receive(:run).with { |callable, env|
env[:action_name].should == hook_name expect(env[:action_name]).to eq(hook_name)
end }
instance.hook(hook_name) instance.hook(hook_name)
end end
it "should return the result of the action runner run" do it "should return the result of the action runner run" do
instance.action_runner.should_receive(:run).and_return(:foo) expect(instance.action_runner).to receive(:run).and_return(:foo)
instance.hook(:bar).should == :foo expect(instance.hook(:bar)).to eq(:foo)
end end
it "should allow passing in a custom action runner" do it "should allow passing in a custom action runner" do
instance.action_runner.should_not_receive(:run) expect(instance.action_runner).not_to receive(:run)
other_runner = double("runner") other_runner = double("runner")
other_runner.should_receive(:run).and_return(:foo) expect(other_runner).to receive(:run).and_return(:foo)
instance.hook(:bar, runner: other_runner).should == :foo expect(instance.hook(:bar, runner: other_runner)).to eq(:foo)
end end
it "should allow passing in custom data" do it "should allow passing in custom data" do
instance.action_runner.should_receive(:run).with do |callable, env| expect(instance.action_runner).to receive(:run).with { |callable, env|
env[:foo].should == :bar expect(env[:foo]).to eq(:bar)
end }
instance.hook(:foo, foo: :bar) instance.hook(:foo, foo: :bar)
end end
it "should allow passing a custom callable" do it "should allow passing a custom callable" do
instance.action_runner.should_receive(:run).with do |callable, env| expect(instance.action_runner).to receive(:run).with { |callable, env|
callable.should == :what expect(callable).to eq(:what)
end }
instance.hook(:foo, callable: :what) instance.hook(:foo, callable: :what)
end end
@ -822,7 +822,7 @@ VF
describe "primary machine name" do describe "primary machine name" do
it "should be the only machine if not a multi-machine environment" do it "should be the only machine if not a multi-machine environment" do
instance.primary_machine_name.should == instance.machine_names.first expect(instance.primary_machine_name).to eq(instance.machine_names.first)
end end
it "should be the machine marked as the primary" do it "should be the machine marked as the primary" do
@ -839,7 +839,7 @@ VF
end end
env = environment.create_vagrant_env env = environment.create_vagrant_env
env.primary_machine_name.should == :bar expect(env.primary_machine_name).to eq(:bar)
end end
it "should be nil if no primary is specified in a multi-machine environment" do it "should be nil if no primary is specified in a multi-machine environment" do
@ -856,7 +856,7 @@ VF
end end
env = environment.create_vagrant_env env = environment.create_vagrant_env
env.primary_machine_name.should be_nil expect(env.primary_machine_name).to be_nil
end end
end end
@ -871,7 +871,7 @@ VF
end end
env = environment.create_vagrant_env env = environment.create_vagrant_env
env.vagrantfile.config.ssh.port.should == 200 expect(env.vagrantfile.config.ssh.port).to eq(200)
end end
it "should load from a custom Vagrantfile" do it "should load from a custom Vagrantfile" do
@ -884,7 +884,7 @@ VF
end end
env = environment.create_vagrant_env(:vagrantfile_name => "non_standard_name") env = environment.create_vagrant_env(:vagrantfile_name => "non_standard_name")
env.vagrantfile.config.ssh.port.should == 200 expect(env.vagrantfile.config.ssh.port).to eq(200)
end end
it "should load from a custom Vagrantfile specified by env var" do it "should load from a custom Vagrantfile specified by env var" do
@ -900,13 +900,13 @@ VF
environment.create_vagrant_env environment.create_vagrant_env
end end
env.vagrantfile.config.ssh.port.should == 400 expect(env.vagrantfile.config.ssh.port).to eq(400)
end end
end end
describe "ui" do describe "ui" do
it "should be a silent UI by default" do it "should be a silent UI by default" do
described_class.new.ui.should be_kind_of(Vagrant::UI::Silent) expect(described_class.new.ui).to be_kind_of(Vagrant::UI::Silent)
end end
it "should be a UI given in the constructor" do it "should be a UI given in the constructor" do
@ -914,13 +914,13 @@ VF
class CustomUI < Vagrant::UI::Interface; end class CustomUI < Vagrant::UI::Interface; end
instance = described_class.new(:ui_class => CustomUI) instance = described_class.new(:ui_class => CustomUI)
instance.ui.should be_kind_of(CustomUI) expect(instance.ui).to be_kind_of(CustomUI)
end end
end end
describe "#unload" do describe "#unload" do
it "should run the unload hook" do it "should run the unload hook" do
instance.should_receive(:hook).with(:environment_unload).once expect(instance).to receive(:hook).with(:environment_unload).once
instance.unload instance.unload
end end
end end
@ -936,7 +936,7 @@ VF
end end
env = isolated_env.create_vagrant_env env = isolated_env.create_vagrant_env
env.machine_names.should == [:default] expect(env.machine_names).to eq([:default])
end end
it "should return the machine names in order" do it "should return the machine names in order" do
@ -951,7 +951,7 @@ VF
end end
env = isolated_env.create_vagrant_env env = isolated_env.create_vagrant_env
env.machine_names.should == [:foo, :bar] expect(env.machine_names).to eq([:foo, :bar])
end end
end end
end end

View File

@ -11,17 +11,20 @@ describe Vagrant::Errors::VagrantError do
subject { klass.new } subject { klass.new }
it "should use the translation for the message" do it "should use the translation for the message" do
subject.to_s.should == "test value" expect(subject.to_s).to eq("test value")
end end
its("status_code") { should eq(1) } describe '#status_code' do
subject { super().status_code }
it { should eq(1) }
end
end end
describe "passing error key through options" do describe "passing error key through options" do
subject { described_class.new(_key: "test_key") } subject { described_class.new(_key: "test_key") }
it "should use the translation for the message" do it "should use the translation for the message" do
subject.to_s.should == "test value" expect(subject.to_s).to eq("test value")
end end
end end
@ -35,7 +38,7 @@ describe Vagrant::Errors::VagrantError do
subject { klass.new(data: "yep") } subject { klass.new(data: "yep") }
it "should use the translation for the message" do it "should use the translation for the message" do
subject.to_s.should == "foo" expect(subject.to_s).to eq("foo")
end end
it "should expose translation keys to the user" do it "should expose translation keys to the user" do

View File

@ -48,7 +48,7 @@ describe Vagrant::Guest do
describe "#detect!" do describe "#detect!" do
it "auto-detects if no explicit guest name given" do it "auto-detects if no explicit guest name given" do
machine.config.vm.stub(guest: nil) machine.config.vm.stub(guest: nil)
subject.should_receive(:initialize_capabilities!). expect(subject).to receive(:initialize_capabilities!).
with(nil, guests, capabilities, machine) with(nil, guests, capabilities, machine)
subject.detect! subject.detect!
@ -56,7 +56,7 @@ describe Vagrant::Guest do
it "uses the explicit guest name if specified" do it "uses the explicit guest name if specified" do
machine.config.vm.stub(guest: :foo) machine.config.vm.stub(guest: :foo)
subject.should_receive(:initialize_capabilities!). expect(subject).to receive(:initialize_capabilities!).
with(:foo, guests, capabilities, machine) with(:foo, guests, capabilities, machine)
subject.detect! subject.detect!
@ -91,12 +91,12 @@ describe Vagrant::Guest do
end end
it "should not be ready by default" do it "should not be ready by default" do
subject.ready?.should_not be expect(subject.ready?).not_to be
end end
it "should be ready after detecting" do it "should be ready after detecting" do
subject.detect! subject.detect!
subject.ready?.should be expect(subject.ready?).to be
end end
end end
end end

View File

@ -10,7 +10,7 @@ describe Vagrant::Host do
let(:env) { Object.new } let(:env) { Object.new }
it "initializes the capabilities" do it "initializes the capabilities" do
described_class.any_instance.should_receive(:initialize_capabilities!). expect_any_instance_of(described_class).to receive(:initialize_capabilities!).
with(:foo, hosts, capabilities, env) with(:foo, hosts, capabilities, env)
described_class.new(:foo, hosts, capabilities, env) described_class.new(:foo, hosts, capabilities, env)

View File

@ -11,16 +11,16 @@ describe Vagrant::MachineState do
it "should give access to the id" do it "should give access to the id" do
instance = described_class.new(id, short, long) instance = described_class.new(id, short, long)
instance.id.should == id expect(instance.id).to eq(id)
end end
it "should give access to the short description" do it "should give access to the short description" do
instance = described_class.new(id, short, long) instance = described_class.new(id, short, long)
instance.short_description.should == short expect(instance.short_description).to eq(short)
end end
it "should give access to the long description" do it "should give access to the long description" do
instance = described_class.new(id, short, long) instance = described_class.new(id, short, long)
instance.long_description.should == long expect(instance.long_description).to eq(long)
end end
end end

View File

@ -62,25 +62,25 @@ describe Vagrant::Machine do
end end
provider_cls = double("provider_cls") provider_cls = double("provider_cls")
provider_cls.should_receive(:new) do |machine| expect(provider_cls).to receive(:new) { |machine|
# Store this for later so we can verify that it is the # Store this for later so we can verify that it is the
# one we expected to receive. # one we expected to receive.
received_machine = machine received_machine = machine
# Sanity check # Sanity check
machine.should be expect(machine).to be
# Yield our machine if we want to do additional tests # Yield our machine if we want to do additional tests
yield machine if block_given? yield machine if block_given?
true true
end.and_return(instance) }.and_return(instance)
# Initialize a new machine and verify that we properly receive # Initialize a new machine and verify that we properly receive
# the machine we expect. # the machine we expect.
instance = described_class.new(name, provider_name, provider_cls, provider_config, instance = described_class.new(name, provider_name, provider_cls, provider_config,
provider_options, config, data_dir, box, provider_options, config, data_dir, box,
env, env.vagrantfile) env, env.vagrantfile)
received_machine.should eql(instance) expect(received_machine).to eql(instance)
end end
it "should initialize with the machine object" do it "should initialize with the machine object" do
@ -90,25 +90,25 @@ describe Vagrant::Machine do
it "should have the machine name setup" do it "should have the machine name setup" do
provider_init_test do |machine| provider_init_test do |machine|
machine.name.should == name expect(machine.name).to eq(name)
end end
end end
it "should have the machine configuration" do it "should have the machine configuration" do
provider_init_test do |machine| provider_init_test do |machine|
machine.config.should eql(config) expect(machine.config).to eql(config)
end end
end end
it "should have the box" do it "should have the box" do
provider_init_test do |machine| provider_init_test do |machine|
machine.box.should eql(box) expect(machine.box).to eql(box)
end end
end end
it "should have the environment" do it "should have the environment" do
provider_init_test do |machine| provider_init_test do |machine|
machine.env.should eql(env) expect(machine.env).to eql(env)
end end
end end
@ -120,29 +120,29 @@ describe Vagrant::Machine do
it "should have access to the ID" do it "should have access to the ID" do
# Stub this because #id= calls it. # Stub this because #id= calls it.
provider.stub(:machine_id_changed) allow(provider).to receive(:machine_id_changed)
# Set the ID on the previous instance so that it is persisted # Set the ID on the previous instance so that it is persisted
instance.id = "foo" instance.id = "foo"
provider_init_test do |machine| provider_init_test do |machine|
machine.id.should == "foo" expect(machine.id).to eq("foo")
end end
end end
it "should NOT have access to the provider" do it "should NOT have access to the provider" do
provider_init_test do |machine| provider_init_test do |machine|
machine.provider.should be_nil expect(machine.provider).to be_nil
end end
end end
it "should initialize the capabilities" do it "should initialize the capabilities" do
instance = double("instance") instance = double("instance")
instance.should_receive(:_initialize).with do |p, m| expect(instance).to receive(:_initialize).with { |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
end }
provider_init_test(instance) provider_init_test(instance)
end end
@ -150,13 +150,40 @@ describe Vagrant::Machine do
end end
describe "attributes" do describe "attributes" do
its(:name) { should eq(name) } describe '#name' do
its(:config) { should eql(config) } subject { super().name }
its(:box) { should eql(box) } it { should eq(name) }
its(:env) { should eql(env) } end
its(:provider) { should eql(provider) }
its(:provider_config) { should eql(provider_config) } describe '#config' do
its(:provider_options) { should eq(provider_options) } subject { super().config }
it { should eql(config) }
end
describe '#box' do
subject { super().box }
it { should eql(box) }
end
describe '#env' do
subject { super().env }
it { should eql(env) }
end
describe '#provider' do
subject { super().provider }
it { should eql(provider) }
end
describe '#provider_config' do
subject { super().provider_config }
it { should eql(provider_config) }
end
describe '#provider_options' do
subject { super().provider_options }
it { should eq(provider_options) }
end
end end
describe "actions" do describe "actions" do
@ -165,9 +192,9 @@ describe Vagrant::Machine do
called = false called = false
callable = lambda { |_env| called = true } callable = lambda { |_env| called = true }
provider.should_receive(:action).with(action_name).and_return(callable) expect(provider).to receive(:action).with(action_name).and_return(callable)
instance.action(:up) instance.action(:up)
called.should be expect(called).to be
end end
it "should provide the machine in the environment" do it "should provide the machine in the environment" do
@ -175,10 +202,10 @@ describe Vagrant::Machine do
machine = nil machine = nil
callable = lambda { |env| machine = env[:machine] } callable = lambda { |env| machine = env[:machine] }
provider.stub(:action).with(action_name).and_return(callable) allow(provider).to receive(:action).with(action_name).and_return(callable)
instance.action(:up) instance.action(:up)
machine.should eql(instance) expect(machine).to eql(instance)
end end
it "should pass any extra options to the environment" do it "should pass any extra options to the environment" do
@ -186,26 +213,26 @@ describe Vagrant::Machine do
foo = nil foo = nil
callable = lambda { |env| foo = env[:foo] } callable = lambda { |env| foo = env[:foo] }
provider.stub(:action).with(action_name).and_return(callable) allow(provider).to receive(:action).with(action_name).and_return(callable)
instance.action(:up, :foo => :bar) instance.action(:up, :foo => :bar)
foo.should == :bar expect(foo).to eq(:bar)
end end
it "should return the environment as a result" do it "should return the environment as a result" do
action_name = :up action_name = :up
callable = lambda { |env| env[:result] = "FOO" } callable = lambda { |env| env[:result] = "FOO" }
provider.stub(:action).with(action_name).and_return(callable) allow(provider).to receive(:action).with(action_name).and_return(callable)
result = instance.action(action_name) result = instance.action(action_name)
result[:result].should == "FOO" expect(result[:result]).to eq("FOO")
end end
it "should raise an exception if the action is not implemented" do it "should raise an exception if the action is not implemented" do
action_name = :up action_name = :up
provider.stub(:action).with(action_name).and_return(nil) allow(provider).to receive(:action).with(action_name).and_return(nil)
expect { instance.action(action_name) }. expect { instance.action(action_name) }.
to raise_error(Vagrant::Errors::UnimplementedProviderAction) to raise_error(Vagrant::Errors::UnimplementedProviderAction)
@ -214,20 +241,20 @@ describe Vagrant::Machine do
describe "communicator" do describe "communicator" do
it "should always return the SSH communicator" do it "should always return the SSH communicator" do
instance.communicate.should be_kind_of(VagrantPlugins::CommunicatorSSH::Communicator) expect(instance.communicate).to be_kind_of(VagrantPlugins::CommunicatorSSH::Communicator)
end end
it "should memoize the result" do it "should memoize the result" do
obj = instance.communicate obj = instance.communicate
instance.communicate.should eql(obj) expect(instance.communicate).to eql(obj)
end end
end end
describe "guest implementation" do describe "guest implementation" do
let(:communicator) do let(:communicator) do
result = double("communicator") result = double("communicator")
result.stub(:ready?).and_return(true) allow(result).to receive(:ready?).and_return(true)
result.stub(:test).and_return(false) allow(result).to receive(:test).and_return(false)
result result
end end
@ -242,11 +269,11 @@ describe Vagrant::Machine do
p.guest(:test) { test_guest } p.guest(:test) { test_guest }
end end
instance.stub(:communicate).and_return(communicator) allow(instance).to receive(:communicate).and_return(communicator)
end end
it "should raise an exception if communication is not ready" do it "should raise an exception if communication is not ready" do
communicator.should_receive(:ready?).and_return(false) expect(communicator).to receive(:ready?).and_return(false)
expect { instance.guest }. expect { instance.guest }.
to raise_error(Vagrant::Errors::MachineGuestNotReady) to raise_error(Vagrant::Errors::MachineGuestNotReady)
@ -254,7 +281,7 @@ describe Vagrant::Machine do
it "should return the configured guest" do it "should return the configured guest" do
result = instance.guest result = instance.guest
result.should be_kind_of(Vagrant::Guest) expect(result).to be_kind_of(Vagrant::Guest)
expect(result).to be_ready expect(result).to be_ready
expect(result.capability_host_chain[0][0]).to eql(:test) expect(result.capability_host_chain[0][0]).to eql(:test)
end end
@ -262,47 +289,47 @@ describe Vagrant::Machine do
describe "setting the ID" do describe "setting the ID" do
before(:each) do before(:each) do
provider.stub(:machine_id_changed) allow(provider).to receive(:machine_id_changed)
end end
it "should not have an ID by default" do it "should not have an ID by default" do
instance.id.should be_nil expect(instance.id).to be_nil
end end
it "should set an ID" do it "should set an ID" do
instance.id = "bar" instance.id = "bar"
instance.id.should == "bar" expect(instance.id).to eq("bar")
end end
it "should notify the machine that the ID changed" do it "should notify the machine that the ID changed" do
provider.should_receive(:machine_id_changed).once expect(provider).to receive(:machine_id_changed).once
instance.id = "bar" instance.id = "bar"
end end
it "should persist the ID" do it "should persist the ID" do
instance.id = "foo" instance.id = "foo"
new_instance.id.should == "foo" expect(new_instance.id).to eq("foo")
end end
it "should delete the ID" do it "should delete the ID" do
instance.id = "foo" instance.id = "foo"
second = new_instance second = new_instance
second.id.should == "foo" expect(second.id).to eq("foo")
second.id = nil second.id = nil
expect(second.id).to be_nil expect(second.id).to be_nil
third = new_instance third = new_instance
third.id.should be_nil expect(third.id).to be_nil
end end
end end
describe "ssh info" do describe "ssh info" do
describe "with the provider returning nil" do describe "with the provider returning nil" do
it "should return nil if the provider returns nil" do it "should return nil if the provider returns nil" do
provider.should_receive(:ssh_info).and_return(nil) expect(provider).to receive(:ssh_info).and_return(nil)
instance.ssh_info.should be_nil expect(instance.ssh_info).to be_nil
end end
end end
@ -310,7 +337,7 @@ describe Vagrant::Machine do
let(:provider_ssh_info) { {} } let(:provider_ssh_info) { {} }
before(:each) do before(:each) do
provider.stub(:ssh_info).and_return(provider_ssh_info) allow(provider).to receive(:ssh_info).and_return(provider_ssh_info)
end end
[:host, :port, :username].each do |type| [:host, :port, :username].each do |type|
@ -318,14 +345,14 @@ describe Vagrant::Machine do
provider_ssh_info[type] = "foo" provider_ssh_info[type] = "foo"
instance.config.ssh.send("#{type}=", nil) instance.config.ssh.send("#{type}=", nil)
instance.ssh_info[type].should == "foo" expect(instance.ssh_info[type]).to eq("foo")
end end
it "should return the Vagrantfile value if provider data not given" do it "should return the Vagrantfile value if provider data not given" do
provider_ssh_info[type] = nil provider_ssh_info[type] = nil
instance.config.ssh.send("#{type}=", "bar") instance.config.ssh.send("#{type}=", "bar")
instance.ssh_info[type].should == "bar" expect(instance.ssh_info[type]).to eq("bar")
end end
it "should use the default if no override and no provider" do it "should use the default if no override and no provider" do
@ -333,7 +360,7 @@ describe Vagrant::Machine do
instance.config.ssh.send("#{type}=", nil) instance.config.ssh.send("#{type}=", nil)
instance.config.ssh.default.send("#{type}=", "foo") instance.config.ssh.default.send("#{type}=", "foo")
instance.ssh_info[type].should == "foo" expect(instance.ssh_info[type]).to eq("foo")
end end
it "should use the override if set even with a provider" do it "should use the override if set even with a provider" do
@ -341,7 +368,7 @@ describe Vagrant::Machine do
instance.config.ssh.send("#{type}=", "bar") instance.config.ssh.send("#{type}=", "bar")
instance.config.ssh.default.send("#{type}=", "foo") instance.config.ssh.default.send("#{type}=", "foo")
instance.ssh_info[type].should == "bar" expect(instance.ssh_info[type]).to eq("bar")
end end
end end
@ -349,53 +376,55 @@ describe Vagrant::Machine do
provider_ssh_info[:forward_agent] = true provider_ssh_info[:forward_agent] = true
instance.config.ssh.forward_agent = false instance.config.ssh.forward_agent = false
instance.ssh_info[:forward_agent].should == false expect(instance.ssh_info[:forward_agent]).to eq(false)
end end
it "should set the configured forward X11 settings" do it "should set the configured forward X11 settings" do
provider_ssh_info[:forward_x11] = true provider_ssh_info[:forward_x11] = true
instance.config.ssh.forward_x11 = false instance.config.ssh.forward_x11 = false
instance.ssh_info[:forward_x11].should == false expect(instance.ssh_info[:forward_x11]).to eq(false)
end end
it "should return the provider private key if given" do it "should return the provider private key if given" do
provider_ssh_info[:private_key_path] = "/foo" provider_ssh_info[:private_key_path] = "/foo"
instance.ssh_info[:private_key_path].should == [File.expand_path("/foo", env.root_path)] expect(instance.ssh_info[:private_key_path]).to eq([File.expand_path("/foo", env.root_path)])
end end
it "should return the configured SSH key path if set" do it "should return the configured SSH key path if set" do
provider_ssh_info[:private_key_path] = nil provider_ssh_info[:private_key_path] = nil
instance.config.ssh.private_key_path = "/bar" instance.config.ssh.private_key_path = "/bar"
instance.ssh_info[:private_key_path].should == [File.expand_path("/bar", env.root_path)] expect(instance.ssh_info[:private_key_path]).to eq([File.expand_path("/bar", env.root_path)])
end end
it "should return the array of SSH keys if set" do it "should return the array of SSH keys if set" do
provider_ssh_info[:private_key_path] = nil provider_ssh_info[:private_key_path] = nil
instance.config.ssh.private_key_path = ["/foo", "/bar"] instance.config.ssh.private_key_path = ["/foo", "/bar"]
instance.ssh_info[:private_key_path].should == [ expect(instance.ssh_info[:private_key_path]).to eq([
File.expand_path("/foo", env.root_path), File.expand_path("/foo", env.root_path),
File.expand_path("/bar", env.root_path), File.expand_path("/bar", env.root_path),
] ])
end end
context "expanding path relative to the root path" do context "expanding path relative to the root path" do
it "should with the provider key path" do it "should with the provider key path" do
provider_ssh_info[:private_key_path] = "~/foo" provider_ssh_info[:private_key_path] = "~/foo"
instance.ssh_info[:private_key_path].should == expect(instance.ssh_info[:private_key_path]).to eq(
[File.expand_path("~/foo", env.root_path)] [File.expand_path("~/foo", env.root_path)]
)
end end
it "should with the config private key path" do it "should with the config private key path" do
provider_ssh_info[:private_key_path] = nil provider_ssh_info[:private_key_path] = nil
instance.config.ssh.private_key_path = "~/bar" instance.config.ssh.private_key_path = "~/bar"
instance.ssh_info[:private_key_path].should == expect(instance.ssh_info[:private_key_path]).to eq(
[File.expand_path("~/bar", env.root_path)] [File.expand_path("~/bar", env.root_path)]
)
end end
end end
@ -403,8 +432,9 @@ describe Vagrant::Machine do
provider_ssh_info[:private_key_path] = nil provider_ssh_info[:private_key_path] = nil
instance.config.ssh.private_key_path = nil instance.config.ssh.private_key_path = nil
instance.ssh_info[:private_key_path].should == expect(instance.ssh_info[:private_key_path]).to eq(
[instance.env.default_private_key_path.to_s] [instance.env.default_private_key_path.to_s]
)
end end
it "should not set any default private keys if a password is specified" do it "should not set any default private keys if a password is specified" do
@ -436,12 +466,12 @@ describe Vagrant::Machine do
it "should query state from the provider" do it "should query state from the provider" do
state = Vagrant::MachineState.new(:id, "short", "long") state = Vagrant::MachineState.new(:id, "short", "long")
provider.should_receive(:state).and_return(state) expect(provider).to receive(:state).and_return(state)
instance.state.id.should == :id expect(instance.state.id).to eq(:id)
end end
it "should raise an exception if a MachineState is not returned" do it "should raise an exception if a MachineState is not returned" do
provider.should_receive(:state).and_return(:old_school) expect(provider).to receive(:state).and_return(:old_school)
expect { instance.state }. expect { instance.state }.
to raise_error(Vagrant::Errors::MachineStateInvalid) to raise_error(Vagrant::Errors::MachineStateInvalid)
end end

View File

@ -34,10 +34,10 @@ 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"
bundler.should_receive(:install).once.with do |plugins, local| expect(bundler).to receive(:install).once.with { |plugins, local|
expect(plugins).to have_key("foo") expect(plugins).to have_key("foo")
expect(local).to be_false expect(local).to be_false
end.and_return(specs) }.and_return(specs)
result = subject.install_plugin("foo") result = subject.install_plugin("foo")
@ -49,14 +49,14 @@ describe Vagrant::Plugin::Manager do
end end
it "masks GemNotFound with our error" do it "masks GemNotFound with our error" do
bundler.should_receive(:install).and_raise(Bundler::GemNotFound) expect(bundler).to receive(:install).and_raise(Bundler::GemNotFound)
expect { subject.install_plugin("foo") }. expect { subject.install_plugin("foo") }.
to raise_error(Vagrant::Errors::PluginGemNotFound) to raise_error(Vagrant::Errors::PluginGemNotFound)
end end
it "masks bundler errors with our own error" do it "masks bundler errors with our own error" do
bundler.should_receive(:install).and_raise(Bundler::InstallError) expect(bundler).to receive(:install).and_raise(Bundler::InstallError)
expect { subject.install_plugin("foo") }. expect { subject.install_plugin("foo") }.
to raise_error(Vagrant::Errors::BundlerError) to raise_error(Vagrant::Errors::BundlerError)
@ -70,14 +70,14 @@ describe Vagrant::Plugin::Manager do
local_spec.name = "bar" local_spec.name = "bar"
local_spec.version = version local_spec.version = version
bundler.should_receive(:install_local).with(name). expect(bundler).to receive(:install_local).with(name).
ordered.and_return(local_spec) ordered.and_return(local_spec)
bundler.should_receive(:install).once.with do |plugins, local| expect(bundler).to receive(:install).once.with { |plugins, local|
expect(plugins).to have_key("bar") expect(plugins).to have_key("bar")
expect(plugins["bar"]["gem_version"]).to eql("#{version}") expect(plugins["bar"]["gem_version"]).to eql("#{version}")
expect(local).to be_true expect(local).to be_true
end.ordered.and_return([local_spec]) }.ordered.and_return([local_spec])
subject.install_plugin(name) subject.install_plugin(name)
@ -94,15 +94,15 @@ describe Vagrant::Plugin::Manager do
end end
before do before do
bundler.stub(:install).and_return(specs) allow(bundler).to receive(:install).and_return(specs)
end end
it "installs a version with constraints" do it "installs a version with constraints" do
bundler.should_receive(:install).once.with do |plugins, local| expect(bundler).to receive(:install).once.with { |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
end.and_return(specs) }.and_return(specs)
subject.install_plugin("foo", version: ">= 0.1.0") subject.install_plugin("foo", version: ">= 0.1.0")
@ -112,11 +112,11 @@ 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
bundler.should_receive(:install).once.with do |plugins, local| expect(bundler).to receive(:install).once.with { |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
end.and_return(specs) }.and_return(specs)
subject.install_plugin("foo", version: "0.1.0") subject.install_plugin("foo", version: "0.1.0")
@ -136,7 +136,7 @@ describe Vagrant::Plugin::Manager do
expect(subject.installed_plugins).to have_key("foo") expect(subject.installed_plugins).to have_key("foo")
# Test # Test
bundler.should_receive(:clean).once.with({}) expect(bundler).to receive(:clean).once.with({})
# Remove it # Remove it
subject.uninstall_plugin("foo") subject.uninstall_plugin("foo")
@ -144,7 +144,7 @@ describe Vagrant::Plugin::Manager do
end end
it "masks bundler errors with our own error" do it "masks bundler errors with our own error" do
bundler.should_receive(:clean).and_raise(Bundler::InstallError) expect(bundler).to receive(:clean).and_raise(Bundler::InstallError)
expect { subject.uninstall_plugin("foo") }. expect { subject.uninstall_plugin("foo") }.
to raise_error(Vagrant::Errors::BundlerError) to raise_error(Vagrant::Errors::BundlerError)
@ -168,7 +168,7 @@ describe Vagrant::Plugin::Manager do
sf.add_plugin("bar") sf.add_plugin("bar")
# Test # Test
bundler.should_receive(:clean).once.with(anything) expect(bundler).to receive(:clean).once.with(anything)
# Remove it # Remove it
subject.uninstall_plugin("bar") subject.uninstall_plugin("bar")
@ -186,7 +186,7 @@ describe Vagrant::Plugin::Manager do
describe "#update_plugins" do describe "#update_plugins" do
it "masks bundler errors with our own error" do it "masks bundler errors with our own error" do
bundler.should_receive(:update).and_raise(Bundler::InstallError) expect(bundler).to receive(:update).and_raise(Bundler::InstallError)
expect { subject.update_plugins([]) }. expect { subject.update_plugins([]) }.
to raise_error(Vagrant::Errors::BundlerError) to raise_error(Vagrant::Errors::BundlerError)

View File

@ -21,20 +21,20 @@ describe Vagrant::Plugin::V1::Command do
result = klass.new(["-f", "foo"], nil).parse_options(opts) result = klass.new(["-f", "foo"], nil).parse_options(opts)
# Check the results # Check the results
options[:f].should be expect(options[:f]).to be
result.should == ["foo"] expect(result).to eq(["foo"])
end end
it "creates an option parser if none is given" do it "creates an option parser if none is given" do
result = klass.new(["foo"], nil).parse_options(nil) result = klass.new(["foo"], nil).parse_options(nil)
result.should == ["foo"] expect(result).to eq(["foo"])
end end
["-h", "--help"].each do |help_string| ["-h", "--help"].each do |help_string|
it "returns nil and prints the help if '#{help_string}' is given" do it "returns nil and prints the help if '#{help_string}' is given" do
instance = klass.new([help_string], nil) instance = klass.new([help_string], nil)
instance.should_receive(:safe_puts) expect(instance).to receive(:safe_puts)
instance.parse_options(OptionParser.new).should be_nil expect(instance.parse_options(OptionParser.new)).to be_nil
end end
end end
@ -70,10 +70,10 @@ describe Vagrant::Plugin::V1::Command do
it "should yield every VM in order is no name is given" do it "should yield every VM in order is no name is given" do
foo_vm = double("foo") foo_vm = double("foo")
foo_vm.stub(:name).and_return("foo") allow(foo_vm).to receive(:name).and_return("foo")
bar_vm = double("bar") bar_vm = double("bar")
bar_vm.stub(:name).and_return("bar") allow(bar_vm).to receive(:name).and_return("bar")
environment.stub(:multivm? => true, environment.stub(:multivm? => true,
:vms => { "foo" => foo_vm, "bar" => bar_vm }, :vms => { "foo" => foo_vm, "bar" => bar_vm },
@ -84,7 +84,7 @@ describe Vagrant::Plugin::V1::Command do
vms << vm vms << vm
end end
vms.should == [foo_vm, bar_vm] expect(vms).to eq([foo_vm, bar_vm])
end end
it "raises an exception if the named VM doesn't exist" do it "raises an exception if the named VM doesn't exist" do
@ -96,14 +96,14 @@ describe Vagrant::Plugin::V1::Command do
it "yields the given VM if a name is given" do it "yields the given VM if a name is given" do
foo_vm = double("foo") foo_vm = double("foo")
foo_vm.stub(:name).and_return(:foo) allow(foo_vm).to receive(:name).and_return(:foo)
environment.stub(:multivm? => true, environment.stub(:multivm? => true,
:vms => { :foo => foo_vm, :bar => nil }) :vms => { :foo => foo_vm, :bar => nil })
vms = [] vms = []
instance.with_target_vms("foo") { |vm| vms << vm } instance.with_target_vms("foo") { |vm| vms << vm }
vms.should == [foo_vm] expect(vms).to eq([foo_vm])
end end
end end
@ -117,27 +117,27 @@ describe Vagrant::Plugin::V1::Command do
it "should work when given all 3 parts" do it "should work when given all 3 parts" do
result = instance.split_main_and_subcommand(["-v", "status", "-h", "-v"]) result = instance.split_main_and_subcommand(["-v", "status", "-h", "-v"])
result.should == [["-v"], "status", ["-h", "-v"]] expect(result).to eq([["-v"], "status", ["-h", "-v"]])
end end
it "should work when given only a subcommand and args" do it "should work when given only a subcommand and args" do
result = instance.split_main_and_subcommand(["status", "-h"]) result = instance.split_main_and_subcommand(["status", "-h"])
result.should == [[], "status", ["-h"]] expect(result).to eq([[], "status", ["-h"]])
end end
it "should work when given only main flags" do it "should work when given only main flags" do
result = instance.split_main_and_subcommand(["-v", "-h"]) result = instance.split_main_and_subcommand(["-v", "-h"])
result.should == [["-v", "-h"], nil, []] expect(result).to eq([["-v", "-h"], nil, []])
end end
it "should work when given only a subcommand" do it "should work when given only a subcommand" do
result = instance.split_main_and_subcommand(["status"]) result = instance.split_main_and_subcommand(["status"])
result.should == [[], "status", []] expect(result).to eq([[], "status", []])
end end
it "works when there are other non-flag args after the subcommand" do it "works when there are other non-flag args after the subcommand" do
result = instance.split_main_and_subcommand(["-v", "box", "add", "-h"]) result = instance.split_main_and_subcommand(["-v", "box", "add", "-h"])
result.should == [["-v"], "box", ["add", "-h"]] expect(result).to eq([["-v"], "box", ["add", "-h"]])
end end
end end
end end

View File

@ -4,6 +4,6 @@ describe Vagrant::Plugin::V1::Communicator do
let(:machine) { Object.new } let(:machine) { Object.new }
it "should not match by default" do it "should not match by default" do
described_class.match?(machine).should_not be expect(described_class.match?(machine)).not_to be
end end
end end

View File

@ -12,8 +12,8 @@ describe Vagrant::Plugin::V1::Config do
it "has an UNSET_VALUE constant" do it "has an UNSET_VALUE constant" do
value = described_class.const_get("UNSET_VALUE") value = described_class.const_get("UNSET_VALUE")
value.should be_kind_of Object expect(value).to be_kind_of Object
value.should eql(described_class.const_get("UNSET_VALUE")) expect(value).to eql(described_class.const_get("UNSET_VALUE"))
end end
describe "merging" do describe "merging" do
@ -26,8 +26,8 @@ describe Vagrant::Plugin::V1::Config do
two.two = 5 two.two = 5
result = one.merge(two) result = one.merge(two)
result.one.should == 2 expect(result.one).to eq(2)
result.two.should == 5 expect(result.two).to eq(5)
end end
it "doesn't merge values that start with a double underscore" do it "doesn't merge values that start with a double underscore" do
@ -42,9 +42,9 @@ describe Vagrant::Plugin::V1::Config do
# Merge and verify # Merge and verify
result = one.merge(two) result = one.merge(two)
result.one.should == 1 expect(result.one).to eq(1)
result.two.should == 2 expect(result.two).to eq(2)
result.instance_variable_get(:@__bar).should be_nil expect(result.instance_variable_get(:@__bar)).to be_nil
end end
end end
end end

View File

@ -23,9 +23,9 @@ describe Vagrant::Plugin::V1::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.communicators.length.should == 2 expect(instance.communicators.length).to eq(2)
instance.communicators[:foo].should == "bar" expect(instance.communicators[:foo]).to eq("bar")
instance.communicators[:bar].should == "baz" expect(instance.communicators[:bar]).to eq("baz")
end end
it "should enumerate registered configuration classes" do it "should enumerate registered configuration classes" do
@ -40,9 +40,9 @@ describe Vagrant::Plugin::V1::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.config.length.should == 2 expect(instance.config.length).to eq(2)
instance.config[:foo].should == "bar" expect(instance.config[:foo]).to eq("bar")
instance.config[:bar].should == "baz" expect(instance.config[:bar]).to eq("baz")
end end
it "should enumerate registered upgrade safe config classes" do it "should enumerate registered upgrade safe config classes" do
@ -57,8 +57,8 @@ describe Vagrant::Plugin::V1::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.config_upgrade_safe.length.should == 1 expect(instance.config_upgrade_safe.length).to eq(1)
instance.config_upgrade_safe[:foo].should == "bar" expect(instance.config_upgrade_safe[:foo]).to eq("bar")
end end
it "should enumerate registered guest classes" do it "should enumerate registered guest classes" do
@ -73,9 +73,9 @@ describe Vagrant::Plugin::V1::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.guests.length.should == 2 expect(instance.guests.length).to eq(2)
instance.guests[:foo].should == "bar" expect(instance.guests[:foo]).to eq("bar")
instance.guests[:bar].should == "baz" expect(instance.guests[:bar]).to eq("baz")
end end
it "should enumerate registered host classes" do it "should enumerate registered host classes" do
@ -90,9 +90,9 @@ describe Vagrant::Plugin::V1::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.hosts.length.should == 2 expect(instance.hosts.length).to eq(2)
instance.hosts[:foo].should == "bar" expect(instance.hosts[:foo]).to eq("bar")
instance.hosts[:bar].should == "baz" expect(instance.hosts[:bar]).to eq("baz")
end end
it "should enumerate registered provider classes" do it "should enumerate registered provider classes" do
@ -107,8 +107,8 @@ describe Vagrant::Plugin::V1::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.providers.length.should == 2 expect(instance.providers.length).to eq(2)
instance.providers[:foo].should == "bar" expect(instance.providers[:foo]).to eq("bar")
instance.providers[:bar].should == "baz" expect(instance.providers[:bar]).to eq("baz")
end end
end end

View File

@ -12,7 +12,7 @@ describe Vagrant::Plugin::V1::Plugin do
name "foo" name "foo"
end end
plugin.name.should == "foo" expect(plugin.name).to eq("foo")
end end
it "should be able to set and get the description" do it "should be able to set and get the description" do
@ -20,7 +20,7 @@ describe Vagrant::Plugin::V1::Plugin do
description "bar" description "bar"
end end
plugin.description.should == "bar" expect(plugin.description).to eq("bar")
end end
describe "action hooks" do describe "action hooks" do
@ -30,8 +30,8 @@ describe Vagrant::Plugin::V1::Plugin do
end end
hooks = plugin.action_hook("foo") hooks = plugin.action_hook("foo")
hooks.length.should == 1 expect(hooks.length).to eq(1)
hooks[0].call.should == "bar" expect(hooks[0].call).to eq("bar")
end end
end end
@ -41,7 +41,7 @@ describe Vagrant::Plugin::V1::Plugin do
command("foo") { "bar" } command("foo") { "bar" }
end end
plugin.command[:foo].should == "bar" expect(plugin.command[:foo]).to eq("bar")
end end
["spaces bad", "sym^bols"].each do |bad| ["spaces bad", "sym^bols"].each do |bad|
@ -78,7 +78,7 @@ describe Vagrant::Plugin::V1::Plugin do
communicator("foo") { "bar" } communicator("foo") { "bar" }
end end
plugin.communicator[:foo].should == "bar" expect(plugin.communicator[:foo]).to eq("bar")
end end
it "should lazily register communicator classes" do it "should lazily register communicator classes" do
@ -106,7 +106,7 @@ describe Vagrant::Plugin::V1::Plugin do
config("foo") { "bar" } config("foo") { "bar" }
end end
plugin.config[:foo].should == "bar" expect(plugin.config[:foo]).to eq("bar")
end end
it "should lazily register configuration classes" do it "should lazily register configuration classes" do
@ -134,7 +134,7 @@ describe Vagrant::Plugin::V1::Plugin do
guest("foo") { "bar" } guest("foo") { "bar" }
end end
plugin.guest[:foo].should == "bar" expect(plugin.guest[:foo]).to eq("bar")
end end
it "should lazily register guest classes" do it "should lazily register guest classes" do
@ -162,7 +162,7 @@ describe Vagrant::Plugin::V1::Plugin do
host("foo") { "bar" } host("foo") { "bar" }
end end
plugin.host[:foo].should == "bar" expect(plugin.host[:foo]).to eq("bar")
end end
it "should lazily register host classes" do it "should lazily register host classes" do
@ -190,7 +190,7 @@ describe Vagrant::Plugin::V1::Plugin do
provider("foo") { "bar" } provider("foo") { "bar" }
end end
plugin.provider[:foo].should == "bar" expect(plugin.provider[:foo]).to eq("bar")
end end
it "should lazily register provider classes" do it "should lazily register provider classes" do
@ -218,7 +218,7 @@ describe Vagrant::Plugin::V1::Plugin do
provisioner("foo") { "bar" } provisioner("foo") { "bar" }
end end
plugin.provisioner[:foo].should == "bar" expect(plugin.provisioner[:foo]).to eq("bar")
end end
it "should lazily register provisioner classes" do it "should lazily register provisioner classes" do
@ -244,7 +244,7 @@ describe Vagrant::Plugin::V1::Plugin do
let(:manager) { described_class.manager } let(:manager) { described_class.manager }
it "should have no registered plugins" do it "should have no registered plugins" do
manager.registered.should be_empty expect(manager.registered).to be_empty
end end
it "should register a plugin when a name is set" do it "should register a plugin when a name is set" do
@ -252,7 +252,7 @@ describe Vagrant::Plugin::V1::Plugin do
name "foo" name "foo"
end end
manager.registered.should == [plugin] expect(manager.registered).to eq([plugin])
end end
it "should register a plugin only once" do it "should register a plugin only once" do
@ -261,7 +261,7 @@ describe Vagrant::Plugin::V1::Plugin do
name "bar" name "bar"
end end
manager.registered.should == [plugin] expect(manager.registered).to eq([plugin])
end end
end end
end end

View File

@ -5,14 +5,14 @@ describe Vagrant::Plugin::V1::Provider do
let(:instance) { described_class.new(machine) } let(:instance) { described_class.new(machine) }
it "should return nil by default for actions" do it "should return nil by default for actions" do
instance.action(:whatever).should be_nil expect(instance.action(:whatever)).to be_nil
end end
it "should return nil by default for ssh info" do it "should return nil by default for ssh info" do
instance.ssh_info.should be_nil expect(instance.ssh_info).to be_nil
end end
it "should return nil by default for state" do it "should return nil by default for state" do
instance.state.should be_nil expect(instance.state).to be_nil
end end
end end

View File

@ -21,20 +21,20 @@ describe Vagrant::Plugin::V2::Command do
result = klass.new(["-f", "foo"], nil).parse_options(opts) result = klass.new(["-f", "foo"], nil).parse_options(opts)
# Check the results # Check the results
options[:f].should be expect(options[:f]).to be
result.should == ["foo"] expect(result).to eq(["foo"])
end end
it "creates an option parser if none is given" do it "creates an option parser if none is given" do
result = klass.new(["foo"], nil).parse_options(nil) result = klass.new(["foo"], nil).parse_options(nil)
result.should == ["foo"] expect(result).to eq(["foo"])
end end
["-h", "--help"].each do |help_string| ["-h", "--help"].each do |help_string|
it "returns nil and prints the help if '#{help_string}' is given" do it "returns nil and prints the help if '#{help_string}' is given" do
instance = klass.new([help_string], nil) instance = klass.new([help_string], nil)
instance.should_receive(:safe_puts) expect(instance).to receive(:safe_puts)
instance.parse_options(OptionParser.new).should be_nil expect(instance.parse_options(OptionParser.new)).to be_nil
end end
end end
@ -82,20 +82,20 @@ describe Vagrant::Plugin::V2::Command do
bar_vm.stub(ui: Vagrant::UI::Silent.new) bar_vm.stub(ui: Vagrant::UI::Silent.new)
environment.stub(:machine_names => [:foo, :bar]) environment.stub(:machine_names => [:foo, :bar])
environment.stub(:machine).with(:foo, default_provider).and_return(foo_vm) allow(environment).to receive(:machine).with(:foo, default_provider).and_return(foo_vm)
environment.stub(:machine).with(:bar, default_provider).and_return(bar_vm) allow(environment).to receive(:machine).with(:bar, default_provider).and_return(bar_vm)
vms = [] vms = []
instance.with_target_vms do |vm| instance.with_target_vms do |vm|
vms << vm vms << vm
end end
vms.should == [foo_vm, bar_vm] expect(vms).to eq([foo_vm, bar_vm])
end end
it "raises an exception if the named VM doesn't exist" do it "raises an exception if the named VM doesn't exist" do
environment.stub(:machine_names => [:default]) environment.stub(:machine_names => [:default])
environment.stub(:machine).with(:foo, anything).and_return(nil) allow(environment).to receive(:machine).with(:foo, anything).and_return(nil)
expect { instance.with_target_vms("foo") }. expect { instance.with_target_vms("foo") }.
to raise_error(Vagrant::Errors::VMNotFoundError) to raise_error(Vagrant::Errors::VMNotFoundError)
@ -106,11 +106,11 @@ describe Vagrant::Plugin::V2::Command do
foo_vm.stub(:name => "foo", :provider => :foobarbaz) foo_vm.stub(:name => "foo", :provider => :foobarbaz)
foo_vm.stub(ui: Vagrant::UI::Silent.new) foo_vm.stub(ui: Vagrant::UI::Silent.new)
environment.stub(:machine).with(:foo, default_provider).and_return(foo_vm) allow(environment).to receive(:machine).with(:foo, default_provider).and_return(foo_vm)
vms = [] vms = []
instance.with_target_vms("foo") { |vm| vms << vm } instance.with_target_vms("foo") { |vm| vms << vm }
vms.should == [foo_vm] expect(vms).to eq([foo_vm])
end end
it "yields the given VM with proper provider if given" do it "yields the given VM with proper provider if given" do
@ -119,11 +119,11 @@ describe Vagrant::Plugin::V2::Command do
foo_vm.stub(:name => "foo", :provider => provider) foo_vm.stub(:name => "foo", :provider => provider)
foo_vm.stub(ui: Vagrant::UI::Silent.new) foo_vm.stub(ui: Vagrant::UI::Silent.new)
environment.stub(:machine).with(:foo, provider).and_return(foo_vm) allow(environment).to receive(:machine).with(:foo, provider).and_return(foo_vm)
vms = [] vms = []
instance.with_target_vms("foo", :provider => provider) { |vm| vms << vm } instance.with_target_vms("foo", :provider => provider) { |vm| vms << vm }
vms.should == [foo_vm] expect(vms).to eq([foo_vm])
end end
it "should raise an exception if an active machine exists with a different provider" do it "should raise an exception if an active machine exists with a different provider" do
@ -140,13 +140,13 @@ describe Vagrant::Plugin::V2::Command do
vmware_vm = double("vmware_vm") vmware_vm = double("vmware_vm")
environment.stub(:active_machines => [[name, provider]]) environment.stub(:active_machines => [[name, provider]])
environment.stub(:machine).with(name, provider).and_return(vmware_vm) allow(environment).to receive(:machine).with(name, provider).and_return(vmware_vm)
vmware_vm.stub(:name => name, :provider => provider) vmware_vm.stub(:name => name, :provider => provider)
vmware_vm.stub(ui: Vagrant::UI::Silent.new) vmware_vm.stub(ui: Vagrant::UI::Silent.new)
vms = [] vms = []
instance.with_target_vms(name.to_s) { |vm| vms << vm } instance.with_target_vms(name.to_s) { |vm| vms << vm }
vms.should == [vmware_vm] expect(vms).to eq([vmware_vm])
end end
it "should use the explicit provider if it maches the active machine" do it "should use the explicit provider if it maches the active machine" do
@ -155,25 +155,25 @@ describe Vagrant::Plugin::V2::Command do
vmware_vm = double("vmware_vm") vmware_vm = double("vmware_vm")
environment.stub(:active_machines => [[name, provider]]) environment.stub(:active_machines => [[name, provider]])
environment.stub(:machine).with(name, provider).and_return(vmware_vm) allow(environment).to receive(:machine).with(name, provider).and_return(vmware_vm)
vmware_vm.stub(:name => name, :provider => provider, ui: Vagrant::UI::Silent.new) vmware_vm.stub(:name => name, :provider => provider, ui: Vagrant::UI::Silent.new)
vms = [] vms = []
instance.with_target_vms(name.to_s, :provider => provider) { |vm| vms << vm } instance.with_target_vms(name.to_s, :provider => provider) { |vm| vms << vm }
vms.should == [vmware_vm] expect(vms).to eq([vmware_vm])
end end
it "should use the default provider if none is given and none are active" do it "should use the default provider if none is given and none are active" do
name = :foo name = :foo
machine = double("machine") machine = double("machine")
environment.stub(:machine).with(name, default_provider).and_return(machine) allow(environment).to receive(:machine).with(name, default_provider).and_return(machine)
machine.stub(:name => name, :provider => default_provider) machine.stub(:name => name, :provider => default_provider)
machine.stub(ui: Vagrant::UI::Silent.new) machine.stub(ui: Vagrant::UI::Silent.new)
results = [] results = []
instance.with_target_vms(name.to_s) { |m| results << m } instance.with_target_vms(name.to_s) { |m| results << m }
results.should == [machine] expect(results).to eq([machine])
end end
it "should use the primary machine with the active provider" do it "should use the primary machine with the active provider" do
@ -182,7 +182,7 @@ describe Vagrant::Plugin::V2::Command do
vmware_vm = double("vmware_vm") vmware_vm = double("vmware_vm")
environment.stub(:active_machines => [[name, provider]]) environment.stub(:active_machines => [[name, provider]])
environment.stub(:machine).with(name, provider).and_return(vmware_vm) allow(environment).to receive(:machine).with(name, provider).and_return(vmware_vm)
environment.stub(:machine_names => []) environment.stub(:machine_names => [])
environment.stub(:primary_machine_name => name) environment.stub(:primary_machine_name => name)
vmware_vm.stub(:name => name, :provider => provider) vmware_vm.stub(:name => name, :provider => provider)
@ -190,7 +190,7 @@ describe Vagrant::Plugin::V2::Command do
vms = [] vms = []
instance.with_target_vms(nil, :single_target => true) { |vm| vms << vm } instance.with_target_vms(nil, :single_target => true) { |vm| vms << vm }
vms.should == [vmware_vm] expect(vms).to eq([vmware_vm])
end end
it "should use the primary machine with the default provider" do it "should use the primary machine with the default provider" do
@ -198,7 +198,7 @@ describe Vagrant::Plugin::V2::Command do
machine = double("machine") machine = double("machine")
environment.stub(:active_machines => []) environment.stub(:active_machines => [])
environment.stub(:machine).with(name, default_provider).and_return(machine) allow(environment).to receive(:machine).with(name, default_provider).and_return(machine)
environment.stub(:machine_names => []) environment.stub(:machine_names => [])
environment.stub(:primary_machine_name => name) environment.stub(:primary_machine_name => name)
machine.stub(:name => name, :provider => default_provider) machine.stub(:name => name, :provider => default_provider)
@ -206,7 +206,7 @@ describe Vagrant::Plugin::V2::Command do
vms = [] vms = []
instance.with_target_vms(nil, :single_target => true) { |vm| vms << machine } instance.with_target_vms(nil, :single_target => true) { |vm| vms << machine }
vms.should == [machine] expect(vms).to eq([machine])
end end
end end
@ -220,27 +220,27 @@ describe Vagrant::Plugin::V2::Command do
it "should work when given all 3 parts" do it "should work when given all 3 parts" do
result = instance.split_main_and_subcommand(["-v", "status", "-h", "-v"]) result = instance.split_main_and_subcommand(["-v", "status", "-h", "-v"])
result.should == [["-v"], "status", ["-h", "-v"]] expect(result).to eq([["-v"], "status", ["-h", "-v"]])
end end
it "should work when given only a subcommand and args" do it "should work when given only a subcommand and args" do
result = instance.split_main_and_subcommand(["status", "-h"]) result = instance.split_main_and_subcommand(["status", "-h"])
result.should == [[], "status", ["-h"]] expect(result).to eq([[], "status", ["-h"]])
end end
it "should work when given only main flags" do it "should work when given only main flags" do
result = instance.split_main_and_subcommand(["-v", "-h"]) result = instance.split_main_and_subcommand(["-v", "-h"])
result.should == [["-v", "-h"], nil, []] expect(result).to eq([["-v", "-h"], nil, []])
end end
it "should work when given only a subcommand" do it "should work when given only a subcommand" do
result = instance.split_main_and_subcommand(["status"]) result = instance.split_main_and_subcommand(["status"])
result.should == [[], "status", []] expect(result).to eq([[], "status", []])
end end
it "works when there are other non-flag args after the subcommand" do it "works when there are other non-flag args after the subcommand" do
result = instance.split_main_and_subcommand(["-v", "box", "add", "-h"]) result = instance.split_main_and_subcommand(["-v", "box", "add", "-h"])
result.should == [["-v"], "box", ["add", "-h"]] expect(result).to eq([["-v"], "box", ["add", "-h"]])
end end
end end
end end

View File

@ -4,6 +4,6 @@ describe Vagrant::Plugin::V2::Communicator do
let(:machine) { Object.new } let(:machine) { Object.new }
it "should not match by default" do it "should not match by default" do
described_class.match?(machine).should_not be expect(described_class.match?(machine)).not_to be
end end
end end

View File

@ -6,16 +6,16 @@ describe Vagrant::Plugin::V2::Components do
subject { described_class.new } subject { described_class.new }
it "should have synced folders" do it "should have synced folders" do
subject.synced_folders.should be_kind_of(Vagrant::Registry) expect(subject.synced_folders).to be_kind_of(Vagrant::Registry)
end end
describe "configs" do describe "configs" do
it "should have configs" do it "should have configs" do
subject.configs.should be_kind_of(Hash) expect(subject.configs).to be_kind_of(Hash)
end end
it "should default the values to registries" do it "should default the values to registries" do
subject.configs[:i_probably_dont_exist].should be_kind_of(Vagrant::Registry) expect(subject.configs[:i_probably_dont_exist]).to be_kind_of(Vagrant::Registry)
end end
end end
end end

View File

@ -24,8 +24,8 @@ describe Vagrant::Plugin::V2::Config do
two.two = 5 two.two = 5
result = one.merge(two) result = one.merge(two)
result.one.should == 2 expect(result.one).to eq(2)
result.two.should == 5 expect(result.two).to eq(5)
end end
it "prefers any set value over an UNSET_VALUE" do it "prefers any set value over an UNSET_VALUE" do
@ -38,8 +38,8 @@ describe Vagrant::Plugin::V2::Config do
two.two = 5 two.two = 5
result = one.merge(two) result = one.merge(two)
result.one.should == 1 expect(result.one).to eq(1)
result.two.should == 5 expect(result.two).to eq(5)
end end
it "doesn't merge values that start with a double underscore" do it "doesn't merge values that start with a double underscore" do
@ -54,9 +54,9 @@ describe Vagrant::Plugin::V2::Config do
# Merge and verify # Merge and verify
result = one.merge(two) result = one.merge(two)
result.one.should == 1 expect(result.one).to eq(1)
result.two.should == 2 expect(result.two).to eq(2)
result.instance_variable_get(:@__bar).should be_nil expect(result.instance_variable_get(:@__bar)).to be_nil
end end
end end

View File

@ -25,9 +25,9 @@ describe Vagrant::Plugin::V2::Manager do
instance.register(pB) instance.register(pB)
result = instance.action_hooks(nil) result = instance.action_hooks(nil)
result.length.should == 2 expect(result.length).to eq(2)
result[0].call.should == "bar" expect(result[0].call).to eq("bar")
result[1].call.should == "baz" expect(result[1].call).to eq("baz")
end end
it "should contain specific hooks with globally registered hooks" do it "should contain specific hooks with globally registered hooks" do
@ -45,10 +45,10 @@ describe Vagrant::Plugin::V2::Manager do
instance.register(pB) instance.register(pB)
result = instance.action_hooks(:foo) result = instance.action_hooks(:foo)
result.length.should == 3 expect(result.length).to eq(3)
result[0].call.should == "bar" expect(result[0].call).to eq("bar")
result[1].call.should == "bar_foo" expect(result[1].call).to eq("bar_foo")
result[2].call.should == "baz" expect(result[2].call).to eq("baz")
end end
end end
@ -64,9 +64,9 @@ describe Vagrant::Plugin::V2::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.communicators.to_hash.length.should == 2 expect(instance.communicators.to_hash.length).to eq(2)
instance.communicators[:foo].should == "bar" expect(instance.communicators[:foo]).to eq("bar")
instance.communicators[:bar].should == "baz" expect(instance.communicators[:bar]).to eq("baz")
end end
it "should enumerate registered configuration classes" do it "should enumerate registered configuration classes" do
@ -81,9 +81,9 @@ describe Vagrant::Plugin::V2::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.config.to_hash.length.should == 2 expect(instance.config.to_hash.length).to eq(2)
instance.config[:foo].should == "bar" expect(instance.config[:foo]).to eq("bar")
instance.config[:bar].should == "baz" expect(instance.config[:bar]).to eq("baz")
end end
it "should enumerate registered guest classes" do it "should enumerate registered guest classes" do
@ -98,9 +98,9 @@ describe Vagrant::Plugin::V2::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.guests.to_hash.length.should == 2 expect(instance.guests.to_hash.length).to eq(2)
instance.guests[:foo].should == ["bar", nil] expect(instance.guests[:foo]).to eq(["bar", nil])
instance.guests[:bar].should == ["baz", :foo] expect(instance.guests[:bar]).to eq(["baz", :foo])
end end
it "should enumerate registered guest capabilities" do it "should enumerate registered guest capabilities" do
@ -115,9 +115,9 @@ describe Vagrant::Plugin::V2::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.guest_capabilities.length.should == 2 expect(instance.guest_capabilities.length).to eq(2)
instance.guest_capabilities[:foo][:foo].should == "bar" expect(instance.guest_capabilities[:foo][:foo]).to eq("bar")
instance.guest_capabilities[:bar][:foo].should == "baz" expect(instance.guest_capabilities[:bar][:foo]).to eq("baz")
end end
it "should enumerate registered host classes" do it "should enumerate registered host classes" do
@ -132,9 +132,9 @@ describe Vagrant::Plugin::V2::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.hosts.to_hash.length.should == 2 expect(instance.hosts.to_hash.length).to eq(2)
instance.hosts[:foo].should == ["bar", nil] expect(instance.hosts[:foo]).to eq(["bar", nil])
instance.hosts[:bar].should == ["baz", :foo] expect(instance.hosts[:bar]).to eq(["baz", :foo])
end end
it "should enumerate registered host capabilities" do it "should enumerate registered host capabilities" do
@ -149,9 +149,9 @@ describe Vagrant::Plugin::V2::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.host_capabilities.length.should == 2 expect(instance.host_capabilities.length).to eq(2)
instance.host_capabilities[:foo][:foo].should == "bar" expect(instance.host_capabilities[:foo][:foo]).to eq("bar")
instance.host_capabilities[:bar][:foo].should == "baz" expect(instance.host_capabilities[:bar][:foo]).to eq("baz")
end end
it "should enumerate registered provider classes" do it "should enumerate registered provider classes" do
@ -166,9 +166,9 @@ describe Vagrant::Plugin::V2::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.providers.to_hash.length.should == 2 expect(instance.providers.to_hash.length).to eq(2)
instance.providers[:foo].should == ["bar", {}] expect(instance.providers[:foo]).to eq(["bar", {}])
instance.providers[:bar].should == ["baz", { foo: "bar" }] expect(instance.providers[:bar]).to eq(["baz", { foo: "bar" }])
end end
it "provides the collection of registered provider configs" do it "provides the collection of registered provider configs" do
@ -184,9 +184,9 @@ describe Vagrant::Plugin::V2::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.provider_configs.to_hash.length.should == 2 expect(instance.provider_configs.to_hash.length).to eq(2)
instance.provider_configs[:foo].should == "foo" expect(instance.provider_configs[:foo]).to eq("foo")
instance.provider_configs[:bar].should == "bar" expect(instance.provider_configs[:bar]).to eq("bar")
end end
it "should enumerate all registered synced folder implementations" do it "should enumerate all registered synced folder implementations" do
@ -201,8 +201,8 @@ describe Vagrant::Plugin::V2::Manager do
instance.register(pA) instance.register(pA)
instance.register(pB) instance.register(pB)
instance.synced_folders.to_hash.length.should == 2 expect(instance.synced_folders.to_hash.length).to eq(2)
instance.synced_folders[:foo].should == ["bar", 10] expect(instance.synced_folders[:foo]).to eq(["bar", 10])
instance.synced_folders[:bar].should == ["baz", 50] expect(instance.synced_folders[:bar]).to eq(["baz", 50])
end end
end end

View File

@ -10,7 +10,7 @@ describe Vagrant::Plugin::V2::Plugin do
name "foo" name "foo"
end end
plugin.name.should == "foo" expect(plugin.name).to eq("foo")
end end
it "should be able to set and get the description" do it "should be able to set and get the description" do
@ -18,7 +18,7 @@ describe Vagrant::Plugin::V2::Plugin do
description "bar" description "bar"
end end
plugin.description.should == "bar" expect(plugin.description).to eq("bar")
end end
describe "action hooks" do describe "action hooks" do
@ -29,8 +29,8 @@ describe Vagrant::Plugin::V2::Plugin do
hooks_registry = plugin.components.action_hooks hooks_registry = plugin.components.action_hooks
hooks = hooks_registry[described_class.const_get("ALL_ACTIONS")] hooks = hooks_registry[described_class.const_get("ALL_ACTIONS")]
hooks.length.should == 1 expect(hooks.length).to eq(1)
hooks[0].call.should == "bar" expect(hooks[0].call).to eq("bar")
end end
it "should register for a specific action by default" do it "should register for a specific action by default" do
@ -40,8 +40,8 @@ describe Vagrant::Plugin::V2::Plugin do
hooks_registry = plugin.components.action_hooks hooks_registry = plugin.components.action_hooks
hooks = hooks_registry[:bar] hooks = hooks_registry[:bar]
hooks.length.should == 1 expect(hooks.length).to eq(1)
hooks[0].call.should == "bar" expect(hooks[0].call).to eq("bar")
end end
end end
@ -109,7 +109,7 @@ describe Vagrant::Plugin::V2::Plugin do
communicator("foo") { "bar" } communicator("foo") { "bar" }
end end
plugin.communicator[:foo].should == "bar" expect(plugin.communicator[:foo]).to eq("bar")
end end
it "should lazily register communicator classes" do it "should lazily register communicator classes" do
@ -137,7 +137,7 @@ describe Vagrant::Plugin::V2::Plugin do
config("foo") { "bar" } config("foo") { "bar" }
end end
plugin.components.configs[:top][:foo].should == "bar" expect(plugin.components.configs[:top][:foo]).to eq("bar")
end end
it "should lazily register configuration classes" do it "should lazily register configuration classes" do
@ -163,7 +163,7 @@ describe Vagrant::Plugin::V2::Plugin do
config("foo", :provider) { "bar" } config("foo", :provider) { "bar" }
end end
plugin.components.configs[:provider][:foo].should == "bar" expect(plugin.components.configs[:provider][:foo]).to eq("bar")
end end
end end
@ -173,7 +173,7 @@ describe Vagrant::Plugin::V2::Plugin do
guest("foo") { "bar" } guest("foo") { "bar" }
end end
plugin.components.guests[:foo].should == ["bar", nil] expect(plugin.components.guests[:foo]).to eq(["bar", nil])
end end
it "should lazily register guest classes" do it "should lazily register guest classes" do
@ -201,7 +201,7 @@ describe Vagrant::Plugin::V2::Plugin do
guest_capability("foo", "bar") { "baz" } guest_capability("foo", "bar") { "baz" }
end end
plugin.components.guest_capabilities[:foo][:bar].should == "baz" expect(plugin.components.guest_capabilities[:foo][:bar]).to eq("baz")
end end
end end
@ -211,7 +211,7 @@ describe Vagrant::Plugin::V2::Plugin do
host("foo") { "bar" } host("foo") { "bar" }
end end
plugin.components.hosts[:foo].should == ["bar", nil] expect(plugin.components.hosts[:foo]).to eq(["bar", nil])
end end
it "should lazily register host classes" do it "should lazily register host classes" do
@ -239,7 +239,7 @@ describe Vagrant::Plugin::V2::Plugin do
host_capability("foo", "bar") { "baz" } host_capability("foo", "bar") { "baz" }
end end
plugin.components.host_capabilities[:foo][:bar].should == "baz" expect(plugin.components.host_capabilities[:foo][:bar]).to eq("baz")
end end
end end
@ -249,7 +249,7 @@ describe Vagrant::Plugin::V2::Plugin do
provider("foo") { "bar" } provider("foo") { "bar" }
end end
plugin.components.providers[:foo].should == ["bar", {}] expect(plugin.components.providers[:foo]).to eq(["bar", {}])
end end
it "should register provider classes with options" do it "should register provider classes with options" do
@ -257,7 +257,7 @@ describe Vagrant::Plugin::V2::Plugin do
provider("foo", foo: "yep") { "bar" } provider("foo", foo: "yep") { "bar" }
end end
plugin.components.providers[:foo].should == ["bar", { foo: "yep" }] expect(plugin.components.providers[:foo]).to eq(["bar", { foo: "yep" }])
end end
it "should lazily register provider classes" do it "should lazily register provider classes" do
@ -285,7 +285,7 @@ describe Vagrant::Plugin::V2::Plugin do
provider_capability("foo", "bar") { "baz" } provider_capability("foo", "bar") { "baz" }
end end
plugin.components.provider_capabilities[:foo][:bar].should == "baz" expect(plugin.components.provider_capabilities[:foo][:bar]).to eq("baz")
end end
end end
@ -295,7 +295,7 @@ describe Vagrant::Plugin::V2::Plugin do
provisioner("foo") { "bar" } provisioner("foo") { "bar" }
end end
plugin.provisioner[:foo].should == "bar" expect(plugin.provisioner[:foo]).to eq("bar")
end end
it "should lazily register provisioner classes" do it "should lazily register provisioner classes" do
@ -323,7 +323,7 @@ describe Vagrant::Plugin::V2::Plugin do
synced_folder("foo") { "bar" } synced_folder("foo") { "bar" }
end end
plugin.components.synced_folders[:foo].should == ["bar", 10] expect(plugin.components.synced_folders[:foo]).to eq(["bar", 10])
end end
it "should be able to specify priorities" do it "should be able to specify priorities" do
@ -331,7 +331,7 @@ describe Vagrant::Plugin::V2::Plugin do
synced_folder("foo", 50) { "bar" } synced_folder("foo", 50) { "bar" }
end end
plugin.components.synced_folders[:foo].should == ["bar", 50] expect(plugin.components.synced_folders[:foo]).to eq(["bar", 50])
end end
it "should lazily register implementations" do it "should lazily register implementations" do
@ -357,7 +357,7 @@ describe Vagrant::Plugin::V2::Plugin do
let(:manager) { described_class.manager } let(:manager) { described_class.manager }
it "should have no registered plugins" do it "should have no registered plugins" do
manager.registered.should be_empty expect(manager.registered).to be_empty
end end
it "should register a plugin when a name is set" do it "should register a plugin when a name is set" do
@ -365,7 +365,7 @@ describe Vagrant::Plugin::V2::Plugin do
name "foo" name "foo"
end end
manager.registered.should == [plugin] expect(manager.registered).to eq([plugin])
end end
it "should register a plugin only once" do it "should register a plugin only once" do
@ -374,7 +374,7 @@ describe Vagrant::Plugin::V2::Plugin do
name "bar" name "bar"
end end
manager.registered.should == [plugin] expect(manager.registered).to eq([plugin])
end end
end end
end end

View File

@ -9,15 +9,15 @@ describe Vagrant::Plugin::V2::Provider do
subject { instance } subject { instance }
it "should return nil by default for actions" do it "should return nil by default for actions" do
instance.action(:whatever).should be_nil expect(instance.action(:whatever)).to be_nil
end end
it "should return nil by default for ssh info" do it "should return nil by default for ssh info" do
instance.ssh_info.should be_nil expect(instance.ssh_info).to be_nil
end end
it "should return nil by default for state" do it "should return nil by default for state" do
instance.state.should be_nil expect(instance.state).to be_nil
end end
context "capabilities" do context "capabilities" do

View File

@ -4,12 +4,12 @@ describe Vagrant::Registry do
let(:instance) { described_class.new } let(:instance) { described_class.new }
it "should return nil for nonexistent items" do it "should return nil for nonexistent items" do
instance.get("foo").should be_nil expect(instance.get("foo")).to be_nil
end end
it "should register a simple key/value" do it "should register a simple key/value" do
instance.register("foo") { "value" } instance.register("foo") { "value" }
instance.get("foo").should == "value" expect(instance.get("foo")).to eq("value")
end end
it "should register an item without calling the block yet" do it "should register an item without calling the block yet" do
@ -31,21 +31,21 @@ describe Vagrant::Registry do
object object
end end
instance.get("foo").should eql(object) expect(instance.get("foo")).to eql(object)
end end
it "should be able to get the item with []" do it "should be able to get the item with []" do
object = Object.new object = Object.new
instance.register("foo") { object } instance.register("foo") { object }
instance["foo"].should eql(object) expect(instance["foo"]).to eql(object)
end end
it "should be able to get keys with #keys" do it "should be able to get keys with #keys" do
instance.register("foo") { "bar" } instance.register("foo") { "bar" }
instance.register("baz") { raise "BOOM" } instance.register("baz") { raise "BOOM" }
instance.keys.sort.should == [ 'baz', 'foo' ] expect(instance.keys.sort).to eq([ 'baz', 'foo' ])
end end
it "should cache the result of the item so they can be modified" do it "should cache the result of the item so they can be modified" do
@ -54,15 +54,15 @@ describe Vagrant::Registry do
# Test that modifying the result modifies the actual cached # Test that modifying the result modifies the actual cached
# value. This verifies we're caching. # value. This verifies we're caching.
instance.get("foo").should == [] expect(instance.get("foo")).to eq([])
instance.get("foo") << "value" instance.get("foo") << "value"
instance.get("foo").should == ["value"] expect(instance.get("foo")).to eq(["value"])
end end
it "should be able to check if a key exists" do it "should be able to check if a key exists" do
instance.register("foo") { "bar" } instance.register("foo") { "bar" }
instance.should have_key("foo") expect(instance).to have_key("foo")
instance.should_not have_key("bar") expect(instance).not_to have_key("bar")
end end
it "should be enumerable" do it "should be enumerable" do
@ -76,8 +76,8 @@ describe Vagrant::Registry do
values << value values << value
end end
keys.sort.should == ["bar", "foo"] expect(keys.sort).to eq(["bar", "foo"])
values.sort.should == ["barvalue", "foovalue"] expect(values.sort).to eq(["barvalue", "foovalue"])
end end
it "should be able to convert to a hash" do it "should be able to convert to a hash" do
@ -85,9 +85,9 @@ describe Vagrant::Registry do
instance.register("bar") { "barvalue" } instance.register("bar") { "barvalue" }
result = instance.to_hash result = instance.to_hash
result.should be_a(Hash) expect(result).to be_a(Hash)
result["foo"].should == "foovalue" expect(result["foo"]).to eq("foovalue")
result["bar"].should == "barvalue" expect(result["bar"]).to eq("barvalue")
end end
describe "merging" do describe "merging" do
@ -114,8 +114,8 @@ describe Vagrant::Registry do
two["bar"] << 2 two["bar"] << 2
three = one.merge(two) three = one.merge(two)
three["foo"].should == [] expect(three["foo"]).to eq([])
three["bar"].should == [] expect(three["bar"]).to eq([])
end end
end end
@ -128,8 +128,8 @@ describe Vagrant::Registry do
two.register("bar") { "bar" } two.register("bar") { "bar" }
one.merge!(two) one.merge!(two)
one["foo"].should == "foo" expect(one["foo"]).to eq("foo")
one["bar"].should == "bar" expect(one["bar"]).to eq("bar")
end end
end end
end end

View File

@ -5,55 +5,55 @@ 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
subject.should_receive(:safe_puts).with do |*args| expect(subject).to receive(:safe_puts).with { |*args|
expect(Thread.current.object_id).to_not eq(current) expect(Thread.current.object_id).to_not eq(current)
true true
end }
subject.output("foo") subject.output("foo")
end end
it "outputs using `puts` by default" do it "outputs using `puts` by default" do
subject.should_receive(:safe_puts).with do |message, **opts| expect(subject).to receive(:safe_puts).with { |message, **opts|
expect(opts[:printer]).to eq(:puts) expect(opts[:printer]).to eq(:puts)
true true
end }
subject.output("foo") subject.output("foo")
end end
it "outputs using `print` if new_line is false" do it "outputs using `print` if new_line is false" do
subject.should_receive(:safe_puts).with do |message, **opts| expect(subject).to receive(:safe_puts).with { |message, **opts|
expect(opts[:printer]).to eq(:print) expect(opts[:printer]).to eq(:print)
true true
end }
subject.output("foo", new_line: false) subject.output("foo", new_line: false)
end end
it "outputs using `print` if new_line is false" do it "outputs using `print` if new_line is false" do
subject.should_receive(:safe_puts).with do |message, **opts| expect(subject).to receive(:safe_puts).with { |message, **opts|
expect(opts[:printer]).to eq(:print) expect(opts[:printer]).to eq(:print)
true true
end }
subject.output("foo", new_line: false) subject.output("foo", new_line: false)
end end
it "outputs to stdout" do it "outputs to stdout" do
subject.should_receive(:safe_puts).with do |message, **opts| expect(subject).to receive(:safe_puts).with { |message, **opts|
expect(opts[:io]).to be($stdout) expect(opts[:io]).to be($stdout)
true true
end }
subject.output("foo") subject.output("foo")
end end
it "outputs to stderr for errors" do it "outputs to stderr for errors" do
subject.should_receive(:safe_puts).with do |message, **opts| expect(subject).to receive(:safe_puts).with { |message, **opts|
expect(opts[:io]).to be($stderr) expect(opts[:io]).to be($stderr)
true true
end }
subject.error("foo") subject.error("foo")
end end
@ -61,16 +61,16 @@ describe Vagrant::UI::Basic do
context "#detail" do context "#detail" do
it "outputs details" do it "outputs details" do
subject.should_receive(:safe_puts).with do |message, **opts| expect(subject).to receive(:safe_puts).with { |message, **opts|
expect(message).to eq("foo") expect(message).to eq("foo")
true true
end }
subject.detail("foo") subject.detail("foo")
end end
it "doesn't output details if disabled" do it "doesn't output details if disabled" do
subject.should_receive(:safe_puts).never expect(subject).to receive(:safe_puts).never
subject.opts[:hide_detail] = true subject.opts[:hide_detail] = true
subject.detail("foo") subject.detail("foo")
@ -83,15 +83,15 @@ describe Vagrant::UI::Colored do
describe "#detail" do describe "#detail" do
it "colors output nothing by default" do it "colors output nothing by default" do
subject.should_receive(:safe_puts).with("\033[0mfoo\033[0m", anything) expect(subject).to receive(:safe_puts).with("\033[0mfoo\033[0m", anything)
subject.detail("foo") subject.detail("foo")
end end
it "does not bold by default with a color" do it "does not bold by default with a color" do
subject.should_receive(:safe_puts).with do |message, *args| expect(subject).to receive(:safe_puts).with { |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")
end }
subject.detail("foo", color: :red) subject.detail("foo", color: :red)
end end
@ -99,10 +99,10 @@ describe Vagrant::UI::Colored do
describe "#error" do describe "#error" do
it "colors red" do it "colors red" do
subject.should_receive(:safe_puts).with do |message, *args| expect(subject).to receive(:safe_puts).with { |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")
end }
subject.error("foo") subject.error("foo")
end end
@ -110,27 +110,27 @@ describe Vagrant::UI::Colored do
describe "#output" do describe "#output" do
it "colors output nothing by default, no bold" do it "colors output nothing by default, no bold" do
subject.should_receive(:safe_puts).with("\033[0mfoo\033[0m", anything) expect(subject).to receive(:safe_puts).with("\033[0mfoo\033[0m", anything)
subject.output("foo") subject.output("foo")
end end
it "doesn't use a color if default color" do it "doesn't use a color if default color" do
subject.should_receive(:safe_puts).with("\033[0mfoo\033[0m", anything) expect(subject).to receive(:safe_puts).with("\033[0mfoo\033[0m", anything)
subject.output("foo", color: :default) subject.output("foo", color: :default)
end end
it "bolds output without color if specified" do it "bolds output without color if specified" do
subject.should_receive(:safe_puts).with("\033[1mfoo\033[0m", anything) expect(subject).to receive(:safe_puts).with("\033[1mfoo\033[0m", anything)
subject.output("foo", bold: true) subject.output("foo", bold: true)
end end
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
subject.should_receive(:safe_puts).with do |message, *args| expect(subject).to receive(:safe_puts).with { |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")
end }
subject.output("foo") subject.output("foo")
end end
@ -138,10 +138,10 @@ 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
subject.should_receive(:safe_puts).with do |message, *args| expect(subject).to receive(:safe_puts).with { |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")
end }
subject.output("foo", color: :green) subject.output("foo", color: :green)
end end
@ -149,10 +149,10 @@ 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
subject.should_receive(:safe_puts).with do |message, *args| expect(subject).to receive(:safe_puts).with { |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")
end }
subject.output("foo", bold: true) subject.output("foo", bold: true)
end end
@ -160,10 +160,10 @@ describe Vagrant::UI::Colored do
describe "#success" do describe "#success" do
it "colors green" do it "colors green" do
subject.should_receive(:safe_puts).with do |message, *args| expect(subject).to receive(:safe_puts).with { |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")
end }
subject.success("foo") subject.success("foo")
end end
@ -171,10 +171,10 @@ describe Vagrant::UI::Colored do
describe "#warn" do describe "#warn" do
it "colors yellow" do it "colors yellow" do
subject.should_receive(:safe_puts).with do |message, *args| expect(subject).to receive(:safe_puts).with { |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")
end }
subject.warn("foo") subject.warn("foo")
end end
@ -191,7 +191,7 @@ describe Vagrant::UI::MachineReadable do
describe "#machine" do describe "#machine" do
it "is formatted properly" do it "is formatted properly" do
subject.should_receive(:safe_puts).with do |message| expect(subject).to receive(:safe_puts).with { |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("")
@ -199,42 +199,42 @@ describe Vagrant::UI::MachineReadable do
expect(parts[3]).to eq("data") expect(parts[3]).to eq("data")
expect(parts[4]).to eq("another") expect(parts[4]).to eq("another")
true true
end }
subject.machine(:type, "data", "another") subject.machine(:type, "data", "another")
end end
it "includes a target if given" do it "includes a target if given" do
subject.should_receive(:safe_puts).with do |message| expect(subject).to receive(:safe_puts).with { |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")
expect(parts[2]).to eq("type") expect(parts[2]).to eq("type")
expect(parts[3]).to eq("data") expect(parts[3]).to eq("data")
true true
end }
subject.machine(:type, "data", target: "boom") subject.machine(:type, "data", target: "boom")
end end
it "replaces commas" do it "replaces commas" do
subject.should_receive(:safe_puts).with do |message| expect(subject).to receive(:safe_puts).with { |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")
true true
end }
subject.machine(:type, "foo,bar") subject.machine(:type, "foo,bar")
end end
it "replaces newlines" do it "replaces newlines" do
subject.should_receive(:safe_puts).with do |message| expect(subject).to receive(:safe_puts).with { |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")
true true
end }
subject.machine(:type, "foo\nbar\r") subject.machine(:type, "foo\nbar\r")
end end
@ -242,12 +242,12 @@ 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
subject.should_receive(:safe_puts).with do |message| expect(subject).to receive(:safe_puts).with { |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")
true true
end }
subject.machine(:type, "foo\nbar\r".freeze) subject.machine(:type, "foo\nbar\r".freeze)
end end
@ -269,36 +269,36 @@ describe Vagrant::UI::Prefixed do
describe "#ask" do describe "#ask" do
it "does not request bolding" do it "does not request bolding" do
ui.should_receive(:ask).with(" #{prefix}: foo", bold: false) expect(ui).to receive(:ask).with(" #{prefix}: foo", bold: false)
subject.ask("foo") subject.ask("foo")
end end
end end
describe "#detail" do describe "#detail" do
it "prefixes with spaces and the message" do it "prefixes with spaces and the message" do
ui.should_receive(:safe_puts).with(" #{prefix}: foo", anything) expect(ui).to receive(:safe_puts).with(" #{prefix}: foo", anything)
subject.detail("foo") subject.detail("foo")
end end
it "prefixes every line" do it "prefixes every line" do
ui.should_receive(:detail).with(" #{prefix}: foo\n #{prefix}: bar", bold: false) expect(ui).to receive(:detail).with(" #{prefix}: foo\n #{prefix}: bar", bold: false)
subject.detail("foo\nbar") subject.detail("foo\nbar")
end end
it "doesn't prefix if requested" do it "doesn't prefix if requested" do
ui.should_receive(:detail).with("foo", prefix: false, bold: false) expect(ui).to receive(:detail).with("foo", prefix: false, bold: false)
subject.detail("foo", prefix: false) subject.detail("foo", prefix: false)
end end
end end
describe "#machine" do describe "#machine" do
it "sets the target option" do it "sets the target option" do
ui.should_receive(:machine).with(:foo, target: prefix) expect(ui).to receive(:machine).with(:foo, target: prefix)
subject.machine(:foo) subject.machine(:foo)
end end
it "preserves existing options" do it "preserves existing options" do
ui.should_receive(:machine).with(:foo, :bar, foo: :bar, target: prefix) expect(ui).to receive(:machine).with(:foo, :bar, foo: :bar, target: prefix)
subject.machine(:foo, :bar, foo: :bar) subject.machine(:foo, :bar, foo: :bar)
end end
end end
@ -312,33 +312,33 @@ describe Vagrant::UI::Prefixed do
describe "#output" do describe "#output" do
it "prefixes with an arrow and the message" do it "prefixes with an arrow and the message" do
ui.should_receive(:output).with("==> #{prefix}: foo", anything) expect(ui).to receive(:output).with("==> #{prefix}: foo", anything)
subject.output("foo") subject.output("foo")
end end
it "prefixes with spaces if requested" do it "prefixes with spaces if requested" do
ui.should_receive(:output).with(" #{prefix}: foo", anything) expect(ui).to receive(:output).with(" #{prefix}: foo", anything)
subject.output("foo", prefix_spaces: true) subject.output("foo", prefix_spaces: true)
end end
it "prefixes every line" do it "prefixes every line" do
ui.should_receive(:output).with("==> #{prefix}: foo\n==> #{prefix}: bar", anything) expect(ui).to receive(:output).with("==> #{prefix}: foo\n==> #{prefix}: bar", anything)
subject.output("foo\nbar") subject.output("foo\nbar")
end end
it "doesn't prefix if requestsed" do it "doesn't prefix if requestsed" do
ui.should_receive(:output).with("foo", prefix: false, bold: true) expect(ui).to receive(:output).with("foo", prefix: false, bold: true)
subject.output("foo", prefix: false) subject.output("foo", prefix: false)
end end
it "requests bolding" do it "requests bolding" do
ui.should_receive(:output).with("==> #{prefix}: foo", bold: true) expect(ui).to receive(:output).with("==> #{prefix}: foo", bold: true)
subject.output("foo") subject.output("foo")
end end
it "does not request bolding if class-level disabled" do it "does not request bolding if class-level disabled" do
ui.opts[:bold] = false ui.opts[:bold] = false
ui.should_receive(:output).with("==> #{prefix}: foo", {}) expect(ui).to receive(:output).with("==> #{prefix}: foo", {})
subject.output("foo") subject.output("foo")
end end
end end

View File

@ -10,7 +10,7 @@ describe Vagrant::Util::ANSIEscapeCodeRemover do
end end
it "should remove ANSI escape codes" do it "should remove ANSI escape codes" do
klass.remove_ansi_escape_codes("\e[Hyo").should == "yo" expect(klass.remove_ansi_escape_codes("\e[Hyo")).to eq("yo")
end end
end end

View File

@ -17,7 +17,7 @@ describe Vagrant::Util::Downloader do
subject { described_class.new(source, destination) } subject { described_class.new(source, destination) }
before :each do before :each do
Vagrant::Util::Subprocess.stub(:execute).and_return(subprocess_result) allow(Vagrant::Util::Subprocess).to receive(:execute).and_return(subprocess_result)
end end
describe "#download!" do describe "#download!" do
@ -31,11 +31,11 @@ describe Vagrant::Util::Downloader do
let(:exit_code) { 0 } let(:exit_code) { 0 }
it "downloads the file and returns true" do it "downloads the file and returns true" do
Vagrant::Util::Subprocess.should_receive(:execute). expect(Vagrant::Util::Subprocess).to receive(:execute).
with("curl", *curl_options). with("curl", *curl_options).
and_return(subprocess_result) and_return(subprocess_result)
subject.download!.should be expect(subject.download!).to be
end end
end end
@ -43,7 +43,7 @@ describe Vagrant::Util::Downloader do
let(:exit_code) { 1 } let(:exit_code) { 1 }
it "raises an exception" do it "raises an exception" do
Vagrant::Util::Subprocess.should_receive(:execute). expect(Vagrant::Util::Subprocess).to receive(:execute).
with("curl", *curl_options). with("curl", *curl_options).
and_return(subprocess_result) and_return(subprocess_result)
@ -65,7 +65,7 @@ describe Vagrant::Util::Downloader do
curl_options.insert(i, "foo:bar") curl_options.insert(i, "foo:bar")
curl_options.insert(i, "-u") curl_options.insert(i, "-u")
Vagrant::Util::Subprocess.should_receive(:execute). expect(Vagrant::Util::Subprocess).to receive(:execute).
with("curl", *curl_options). with("curl", *curl_options).
and_return(subprocess_result) and_return(subprocess_result)
@ -85,7 +85,7 @@ describe Vagrant::Util::Downloader do
options = curl_options.dup options = curl_options.dup
options.unshift("-I") options.unshift("-I")
Vagrant::Util::Subprocess.should_receive(:execute). expect(Vagrant::Util::Subprocess).to receive(:execute).
with("curl", *options).and_return(subprocess_result) with("curl", *options).and_return(subprocess_result)
expect(subject.head).to eq("foo") expect(subject.head).to eq("foo")

View File

@ -15,9 +15,9 @@ describe FileChecksum do
# Check multiple digests # Check multiple digests
instance = described_class.new(file, Digest::MD5) instance = described_class.new(file, Digest::MD5)
instance.checksum.should == "9ac96c64417b5976a58839eceaa77956" expect(instance.checksum).to eq("9ac96c64417b5976a58839eceaa77956")
instance = described_class.new(file, Digest::SHA1) instance = described_class.new(file, Digest::SHA1)
instance.checksum.should == "264b207c7913e461c43d0f63d2512f4017af4755" expect(instance.checksum).to eq("264b207c7913e461c43d0f63d2512f4017af4755")
end end
end end

View File

@ -6,25 +6,25 @@ describe Vagrant::Util::HashWithIndifferentAccess do
let(:instance) { described_class.new } let(:instance) { described_class.new }
it "is a Hash" do it "is a Hash" do
instance.should be_kind_of(Hash) expect(instance).to be_kind_of(Hash)
end end
it "allows indifferent access when setting with a string" do it "allows indifferent access when setting with a string" do
instance["foo"] = "bar" instance["foo"] = "bar"
instance[:foo].should == "bar" expect(instance[:foo]).to eq("bar")
end end
it "allows indifferent access when setting with a symbol" do it "allows indifferent access when setting with a symbol" do
instance[:foo] = "bar" instance[:foo] = "bar"
instance["foo"].should == "bar" expect(instance["foo"]).to eq("bar")
end end
it "allows indifferent key lookup" do it "allows indifferent key lookup" do
instance["foo"] = "bar" instance["foo"] = "bar"
instance.key?(:foo).should be expect(instance.key?(:foo)).to be
instance.has_key?(:foo).should be expect(instance.has_key?(:foo)).to be
instance.include?(:foo).should be expect(instance.include?(:foo)).to be
instance.member?(:foo).should be expect(instance.member?(:foo)).to be
end end
it "allows for defaults to be passed in via an initializer block" do it "allows for defaults to be passed in via an initializer block" do
@ -32,7 +32,7 @@ describe Vagrant::Util::HashWithIndifferentAccess do
h[k] = "foo" h[k] = "foo"
end end
instance[:foo].should == "foo" expect(instance[:foo]).to eq("foo")
instance["bar"].should == "foo" expect(instance["bar"]).to eq("foo")
end end
end end

View File

@ -36,7 +36,7 @@ describe Vagrant::Util::IsPortOpen do
end end
# Verify that we report the port is open # Verify that we report the port is open
klass.is_port_open?("localhost", open_port).should be expect(klass.is_port_open?("localhost", open_port)).to be
# Kill the thread # Kill the thread
thr[:die] = true thr[:die] = true
@ -47,7 +47,7 @@ describe Vagrant::Util::IsPortOpen do
# This CAN fail, since port 52811 might actually be in use, but I'm # This CAN fail, since port 52811 might actually be in use, but I'm
# not sure what to do except choose some random port and hope for the # not sure what to do except choose some random port and hope for the
# best, really. # best, really.
klass.is_port_open?("localhost", closed_port).should_not be expect(klass.is_port_open?("localhost", closed_port)).not_to be
end end
end end

View File

@ -10,7 +10,7 @@ describe Vagrant::Util::LineEndingHelpers do
end end
it "should convert DOS to unix-style line endings" do it "should convert DOS to unix-style line endings" do
klass.dos_to_unix("foo\r\nbar\r\n").should == "foo\nbar\n" expect(klass.dos_to_unix("foo\r\nbar\r\n")).to eq("foo\nbar\n")
end end
end end

View File

@ -11,7 +11,7 @@ describe Vagrant::Util::NetworkIP do
describe "network address" do describe "network address" do
it "calculates it properly" do it "calculates it properly" do
klass.network_address("192.168.2.234", "255.255.255.0").should == "192.168.2.0" expect(klass.network_address("192.168.2.234", "255.255.255.0")).to eq("192.168.2.0")
end end
end end
end end

View File

@ -22,7 +22,7 @@ describe Vagrant::Util::Retryable do
to raise_error(RuntimeError) to raise_error(RuntimeError)
# It should've tried once # It should've tried once
tries.should == 1 expect(tries).to eq(1)
end end
it "retries the set number of times" do it "retries the set number of times" do
@ -38,7 +38,7 @@ describe Vagrant::Util::Retryable do
to raise_error(RuntimeError) to raise_error(RuntimeError)
# It should've tried all specified times # It should've tried all specified times
tries.should == 5 expect(tries).to eq(5)
end end
it "only retries on the given exception" do it "only retries on the given exception" do
@ -54,7 +54,7 @@ describe Vagrant::Util::Retryable do
to raise_error(StandardError) to raise_error(StandardError)
# It should've never tried since it was a different kind of error # It should've never tried since it was a different kind of error
tries.should == 1 expect(tries).to eq(1)
end end
it "can retry on multiple types of errors" do it "can retry on multiple types of errors" do
@ -75,7 +75,7 @@ describe Vagrant::Util::Retryable do
to raise_error(RuntimeError) to raise_error(RuntimeError)
# It should've never tried since it was a different kind of error # It should've never tried since it was a different kind of error
tries.should == 3 expect(tries).to eq(3)
end end
it "doesn't sleep between tries by default" do it "doesn't sleep between tries by default" do
@ -84,7 +84,7 @@ describe Vagrant::Util::Retryable do
end end
# Sleep should never be called # Sleep should never be called
klass.should_not_receive(:sleep) expect(klass).not_to receive(:sleep)
# Run it. # Run it.
expect { klass.retryable(:tries => 5, &block) }. expect { klass.retryable(:tries => 5, &block) }.
@ -97,7 +97,7 @@ describe Vagrant::Util::Retryable do
end end
# Sleep should be called between each retry # Sleep should be called between each retry
klass.should_receive(:sleep).with(10).exactly(4).times expect(klass).to receive(:sleep).with(10).exactly(4).times
# Run it. # Run it.
expect { klass.retryable(:tries => 5, :sleep => 10, &block) }. expect { klass.retryable(:tries => 5, :sleep => 10, &block) }.

View File

@ -18,7 +18,7 @@ describe Vagrant::Util::SafeChdir do
result = Dir.pwd result = Dir.pwd
end end
result.should == expected expect(result).to eq(expected)
end end
it "should allow recursive chdir" do it "should allow recursive chdir" do
@ -38,6 +38,6 @@ describe Vagrant::Util::SafeChdir do
end end
end.to_not raise_error end.to_not raise_error
result.should == expected expect(result).to eq(expected)
end end
end end

View File

@ -15,7 +15,7 @@ describe Vagrant::Util::ScopedHashOverride do
:another_value => "foo" :another_value => "foo"
} }
klass.scoped_hash_override(original, "foo").should == original expect(klass.scoped_hash_override(original, "foo")).to eq(original)
end end
it "should override if the scope matches" do it "should override if the scope matches" do
@ -28,7 +28,7 @@ describe Vagrant::Util::ScopedHashOverride do
:key => "replaced" :key => "replaced"
} }
klass.scoped_hash_override(original, "scope").should == expected expect(klass.scoped_hash_override(original, "scope")).to eq(expected)
end end
it "should ignore non-matching scopes" do it "should ignore non-matching scopes" do
@ -43,6 +43,6 @@ describe Vagrant::Util::ScopedHashOverride do
:another__key => "value" :another__key => "value"
} }
klass.scoped_hash_override(original, "scope").should == expected expect(klass.scoped_hash_override(original, "scope")).to eq(expected)
end end
end end

View File

@ -10,21 +10,21 @@ describe Vagrant::Util::SSH do
let(:key_path) { temporary_file } let(:key_path) { temporary_file }
it "should do nothing on Windows" do it "should do nothing on Windows" do
Vagrant::Util::Platform.stub(:windows?).and_return(true) allow(Vagrant::Util::Platform).to receive(:windows?).and_return(true)
key_path.chmod(0700) key_path.chmod(0700)
# Get the mode now and verify that it is untouched afterwards # Get the mode now and verify that it is untouched afterwards
mode = key_path.stat.mode mode = key_path.stat.mode
described_class.check_key_permissions(key_path) described_class.check_key_permissions(key_path)
key_path.stat.mode.should == mode expect(key_path.stat.mode).to eq(mode)
end end
it "should fix the permissions", :skip_windows do it "should fix the permissions", :skip_windows do
key_path.chmod(0644) key_path.chmod(0644)
described_class.check_key_permissions(key_path) described_class.check_key_permissions(key_path)
key_path.stat.mode.should == 0100600 expect(key_path.stat.mode).to eq(0100600)
end end
end end
end end

View File

@ -15,7 +15,7 @@ content
# VAGRANT-END: bar # VAGRANT-END: bar
DATA DATA
described_class.new(data).keys.should == ["foo", "bar"] expect(described_class.new(data).keys).to eq(["foo", "bar"])
end end
end end
@ -25,7 +25,7 @@ DATA
instance = described_class.new(data) instance = described_class.new(data)
instance.delete("key") instance.delete("key")
instance.value.should == data expect(instance.value).to eq(data)
end end
it "should delete the matching blocks if they exist" do it "should delete the matching blocks if they exist" do
@ -51,7 +51,7 @@ DATA
instance = described_class.new(data) instance = described_class.new(data)
instance.delete("foo") instance.delete("foo")
instance.value.should == new_data expect(instance.value).to eq(new_data)
end end
end end
@ -70,16 +70,16 @@ DATA
subject { described_class.new(data) } subject { described_class.new(data) }
it "should get the value" do it "should get the value" do
subject.get("bar").should == "content" expect(subject.get("bar")).to eq("content")
end end
it "should get nil for nonexistent values" do it "should get nil for nonexistent values" do
subject.get("baz").should be_nil expect(subject.get("baz")).to be_nil
end end
it "should get complicated keys" do it "should get complicated keys" do
result = subject.get("/Users/studio/Projects (studio)/tubes/.vagrant/machines/web/vmware_fusion/vm.vmwarevm") result = subject.get("/Users/studio/Projects (studio)/tubes/.vagrant/machines/web/vmware_fusion/vm.vmwarevm")
result.should == "complex" expect(result).to eq("complex")
end end
end end
@ -100,7 +100,7 @@ DATA
instance = described_class.new(data) instance = described_class.new(data)
instance.insert("foo", "value") instance.insert("foo", "value")
instance.value.should == new_data expect(instance.value).to eq(new_data)
end end
end end
end end

View File

@ -23,21 +23,21 @@ describe Vagrant::Util::Which do
it "should return a path for an executable file" do it "should return a path for an executable file" do
tester '.bat', '.bat', 0755 do |name| tester '.bat', '.bat', 0755 do |name|
described_class.which(name).should_not be_nil expect(described_class.which(name)).not_to be_nil
end end
end end
if Vagrant::Util::Platform.windows? if Vagrant::Util::Platform.windows?
it "should return a path for a Windows executable file" do it "should return a path for a Windows executable file" do
tester '.bat', '', 0755 do |name| tester '.bat', '', 0755 do |name|
described_class.which(name).should_not be_nil expect(described_class.which(name)).not_to be_nil
end end
end end
end end
it "should return nil for a non-executable file" do it "should return nil for a non-executable file" do
tester '.txt', '.txt', 0644 do |name| tester '.txt', '.txt', 0644 do |name|
described_class.which(name).should be_nil expect(described_class.which(name)).to be_nil
end end
end end
end end

View File

@ -79,12 +79,35 @@ describe Vagrant::Vagrantfile do
VF VF
end end
its(:data_dir) { should eq(data_path) } describe '#data_dir' do
its(:env) { should equal(env) } subject { super().data_dir }
its(:name) { should eq(:default) } it { should eq(data_path) }
its(:provider) { should be_kind_of(@provider_cls) } end
its(:provider_name) { should eq(:foo) }
its(:vagrantfile) { should equal(vagrantfile) } describe '#env' do
subject { super().env }
it { should equal(env) }
end
describe '#name' do
subject { super().name }
it { should eq(:default) }
end
describe '#provider' do
subject { super().provider }
it { should be_kind_of(@provider_cls) }
end
describe '#provider_name' do
subject { super().provider_name }
it { should eq(:foo) }
end
describe '#vagrantfile' do
subject { super().vagrantfile }
it { should equal(vagrantfile) }
end
it "has the proper box" do it "has the proper box" do
expect(subject.box.name).to eq("foo") expect(subject.box.name).to eq("foo")

View File

@ -4,40 +4,40 @@ describe Vagrant do
include_context "unit" include_context "unit"
it "has the path to the source root" do it "has the path to the source root" do
described_class.source_root.should == Pathname.new(File.expand_path("../../../", __FILE__)) expect(described_class.source_root).to eq(Pathname.new(File.expand_path("../../../", __FILE__)))
end end
describe "plugin superclass" do describe "plugin superclass" do
describe "v1" do describe "v1" do
it "returns the proper class for version 1" do it "returns the proper class for version 1" do
described_class.plugin("1").should == Vagrant::Plugin::V1::Plugin expect(described_class.plugin("1")).to eq(Vagrant::Plugin::V1::Plugin)
end end
it "returns the proper components for version 1" do it "returns the proper components for version 1" do
described_class.plugin("1", :command).should == Vagrant::Plugin::V1::Command expect(described_class.plugin("1", :command)).to eq(Vagrant::Plugin::V1::Command)
described_class.plugin("1", :communicator).should == Vagrant::Plugin::V1::Communicator expect(described_class.plugin("1", :communicator)).to eq(Vagrant::Plugin::V1::Communicator)
described_class.plugin("1", :config).should == Vagrant::Plugin::V1::Config expect(described_class.plugin("1", :config)).to eq(Vagrant::Plugin::V1::Config)
described_class.plugin("1", :guest).should == Vagrant::Plugin::V1::Guest expect(described_class.plugin("1", :guest)).to eq(Vagrant::Plugin::V1::Guest)
described_class.plugin("1", :host).should == Vagrant::Plugin::V1::Host expect(described_class.plugin("1", :host)).to eq(Vagrant::Plugin::V1::Host)
described_class.plugin("1", :provider).should == Vagrant::Plugin::V1::Provider expect(described_class.plugin("1", :provider)).to eq(Vagrant::Plugin::V1::Provider)
described_class.plugin("1", :provisioner).should == Vagrant::Plugin::V1::Provisioner expect(described_class.plugin("1", :provisioner)).to eq(Vagrant::Plugin::V1::Provisioner)
end end
end end
describe "v2" do describe "v2" do
it "returns the proper class for version 2" do it "returns the proper class for version 2" do
described_class.plugin("2").should == Vagrant::Plugin::V2::Plugin expect(described_class.plugin("2")).to eq(Vagrant::Plugin::V2::Plugin)
end end
it "returns the proper components for version 2" do it "returns the proper components for version 2" do
described_class.plugin("2", :command).should == Vagrant::Plugin::V2::Command expect(described_class.plugin("2", :command)).to eq(Vagrant::Plugin::V2::Command)
described_class.plugin("2", :communicator).should == Vagrant::Plugin::V2::Communicator expect(described_class.plugin("2", :communicator)).to eq(Vagrant::Plugin::V2::Communicator)
described_class.plugin("2", :config).should == Vagrant::Plugin::V2::Config expect(described_class.plugin("2", :config)).to eq(Vagrant::Plugin::V2::Config)
described_class.plugin("2", :guest).should == Vagrant::Plugin::V2::Guest expect(described_class.plugin("2", :guest)).to eq(Vagrant::Plugin::V2::Guest)
described_class.plugin("2", :host).should == Vagrant::Plugin::V2::Host expect(described_class.plugin("2", :host)).to eq(Vagrant::Plugin::V2::Host)
described_class.plugin("2", :provider).should == Vagrant::Plugin::V2::Provider expect(described_class.plugin("2", :provider)).to eq(Vagrant::Plugin::V2::Provider)
described_class.plugin("2", :provisioner).should == Vagrant::Plugin::V2::Provisioner expect(described_class.plugin("2", :provisioner)).to eq(Vagrant::Plugin::V2::Provisioner)
described_class.plugin("2", :synced_folder).should == Vagrant::Plugin::V2::SyncedFolder expect(described_class.plugin("2", :synced_folder)).to eq(Vagrant::Plugin::V2::SyncedFolder)
end end
end end