Fix failing tests

This commit is contained in:
Seth Vargo 2016-06-22 18:35:19 -07:00
parent b621cc44fb
commit 66cbe7b41e
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
6 changed files with 25 additions and 23 deletions

View File

@ -20,18 +20,18 @@ describe "VagrantPlugins::GuestArch::Cap::ChangeHostName" do
end
describe ".change_host_name" do
let(:hostname) { "banana-rama.example.com" }
let(:name) { "banana-rama.example.com" }
it "sets the hostname" do
comm.stub_command("hostname | grep -w '#{hostname}'", exit_code: 1)
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
described_class.change_host_name(machine, hostname)
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname '#{hostname}'/)
described_class.change_host_name(machine, name)
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname 'banana-rama'/)
end
it "does not change the hostname if already set" do
comm.stub_command("hostname | grep -w '#{hostname}'", exit_code: 0)
described_class.change_host_name(machine, hostname)
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
described_class.change_host_name(machine, name)
expect(comm.received_commands.size).to eq(1)
end
end

View File

@ -1,11 +1,10 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestArch::Cap::ConfigureNetworks" do
let(:described_class) do
let(:caps) do
VagrantPlugins::GuestArch::Plugin
.components
.guest_capabilities[:arch]
.get(:configure_networks)
end
let(:machine) { double("machine") }
@ -22,6 +21,8 @@ describe "VagrantPlugins::GuestArch::Cap::ConfigureNetworks" do
end
describe ".configure_networks" do
let(:cap) { caps.get(:configure_networks) }
let(:network_1) do
{
interface: 0,
@ -40,7 +41,7 @@ describe "VagrantPlugins::GuestArch::Cap::ConfigureNetworks" do
end
it "creates and starts the networks" do
described_class.configure_networks(machine, [network_1, network_2])
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[1]).to match(/mv (.+) '\/etc\/netctl\/eth1'/)
expect(comm.received_commands[1]).to match(/ip link set 'eth1' down/)
expect(comm.received_commands[1]).to match(/netctl restart 'eth1'/)

View File

@ -1,11 +1,10 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestAtomic::Cap::ChangeHostName" do
let(:described_class) do
let(:caps) do
VagrantPlugins::GuestAtomic::Plugin
.components
.guest_capabilities[:atomic]
.get(:change_host_name)
end
let(:machine) { double("machine") }
@ -20,18 +19,20 @@ describe "VagrantPlugins::GuestAtomic::Cap::ChangeHostName" do
end
describe ".change_host_name" do
let(:hostname) { "banana-rama.example.com" }
let(:cap) { caps.get(:change_host_name) }
let(:name) { "banana-rama.example.com" }
it "sets the hostname" do
comm.stub_command("hostname | grep -w '#{hostname}'", exit_code: 1)
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
described_class.change_host_name(machine, hostname)
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname '#{hostname}'/)
cap.change_host_name(machine, name)
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname 'banana-rama'/)
end
it "does not change the hostname if already set" do
comm.stub_command("hostname | grep -w '#{hostname}'", exit_code: 0)
described_class.change_host_name(machine, hostname)
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
cap.change_host_name(machine, name)
expect(comm.received_commands.size).to eq(1)
end
end

View File

@ -22,12 +22,12 @@ describe "VagrantPlugins::GuestBSD::Cap::Halt" do
let(:cap) { caps.get(:halt) }
it "runs the shutdown command" do
comm.expect_command("/sbin/shutdown -p -h now")
comm.expect_command("/sbin/shutdown -p now")
cap.halt(machine)
end
it "ignores an IOError" do
comm.stub_command("/sbin/shutdown -p -h now", raise: IOError)
comm.stub_command("/sbin/shutdown -p now", raise: IOError)
expect {
cap.halt(machine)
}.to_not raise_error

View File

@ -24,7 +24,7 @@ describe "VagrantPlugins::GuestDebian::Cap::ChangeHostName" do
let(:name) { 'banana-rama.example.com' }
it "sets the hostname if not set" do
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 1)
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
cap.change_host_name(machine, name)
expect(comm.received_commands[1]).to match(/hostname -F \/etc\/hostname/)
expect(comm.received_commands[1]).to match(/invoke-rc.d hostname.sh start/)
@ -33,7 +33,7 @@ describe "VagrantPlugins::GuestDebian::Cap::ChangeHostName" do
end
it "does not set the hostname if unset" do
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 0)
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
cap.change_host_name(machine, name)
expect(comm.received_commands.size).to eq(1)
end

View File

@ -23,7 +23,7 @@ describe "VagrantPlugins::GuestFreeBSD::Cap::ChangeHostName" do
let(:name) { "banana-rama.example.com" }
it "sets the hostname and /etc/hosts" do
comm.stub_command("hostname -f | grep -w '#{name}' || hostname -s | grep -w '#{name}'", exit_code: 1)
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
described_class.change_host_name(machine, name)
expect(comm.received_commands[1]).to match(/hostname '#{name}'/)
@ -32,7 +32,7 @@ describe "VagrantPlugins::GuestFreeBSD::Cap::ChangeHostName" do
end
it "does nothing if the hostname is already set" do
comm.stub_command("hostname -f | grep -w '#{name}' || hostname -s | grep -w '#{name}'", exit_code: 0)
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
described_class.change_host_name(machine, name)
expect(comm.received_commands.size).to eq(1)
end