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 end
describe ".change_host_name" do describe ".change_host_name" do
let(:hostname) { "banana-rama.example.com" } let(:name) { "banana-rama.example.com" }
it "sets the hostname" do 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) described_class.change_host_name(machine, name)
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname '#{hostname}'/) expect(comm.received_commands[1]).to match(/hostnamectl set-hostname 'banana-rama'/)
end end
it "does not change the hostname if already set" do it "does not change the hostname if already set" do
comm.stub_command("hostname | grep -w '#{hostname}'", exit_code: 0) comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
described_class.change_host_name(machine, hostname) described_class.change_host_name(machine, name)
expect(comm.received_commands.size).to eq(1) expect(comm.received_commands.size).to eq(1)
end end
end end

View File

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

View File

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

View File

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

View File

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

View File

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