spec/unit/plugins/hostname_spec.rb in ohai-15.1.5 vs spec/unit/plugins/hostname_spec.rb in ohai-15.2.5
- old
+ new
@@ -62,13 +62,15 @@
context "hostname --fqdn when it returns empty string" do
before(:each) do
allow(@plugin).to receive(:collect_os).and_return(:linux)
allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(
- mock_shell_out(0, "katie", ""))
+ mock_shell_out(0, "katie", "")
+ )
allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
- mock_shell_out(0, "", ""), mock_shell_out(0, "katie.local", ""))
+ mock_shell_out(0, "", ""), mock_shell_out(0, "katie.local", "")
+ )
end
it "should be called twice" do
@plugin.run
expect(@plugin[:fqdn]).to eq("katie.local")
@@ -77,13 +79,15 @@
context "hostname --fqdn when it works" do
before(:each) do
allow(@plugin).to receive(:collect_os).and_return(:linux)
allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(
- mock_shell_out(0, "katie", ""))
+ mock_shell_out(0, "katie", "")
+ )
allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
- mock_shell_out(0, "katie.local", ""))
+ mock_shell_out(0, "katie.local", "")
+ )
end
it "should be not be called twice" do
@plugin.run
expect(@plugin[:fqdn]).to eq("katie.local")
@@ -107,50 +111,50 @@
[],
23,
"address1",
"address2",
"address3",
- "address4"
+ "address4",
]
end
let(:local_hostent) do
[
"local",
[],
23,
- "address"
+ "address",
]
end
let(:fqdn_hostent) do
[
"local.dx.internal.cloudapp.net",
[],
23,
- "address"
+ "address",
]
end
before(:each) do
@plugin = get_plugin("hostname")
allow(WmiLite::Wmi).to receive(:new).and_return(success)
allow(success).to receive(:first_of).with("Win32_ComputerSystem").and_return(host)
allow(Socket).to receive(:gethostname).and_return("local")
- allow(Socket).to receive(:gethostbyname).with(anything()).and_return(info)
+ allow(Socket).to receive(:gethostbyname).with(anything).and_return(info)
end
context "when hostname is not set for the machine" do
it "should return short machine name" do
- allow(Socket).to receive(:gethostbyaddr).with(anything()).and_return(local_hostent)
+ allow(Socket).to receive(:gethostbyaddr).with(anything).and_return(local_hostent)
@plugin.run
expect(@plugin[:fqdn]).to eq("local")
end
end
context "when hostname is set for the machine" do
it "should return the fqdn of the machine" do
- allow(Socket).to receive(:gethostbyaddr).with(anything()).and_return(fqdn_hostent)
+ allow(Socket).to receive(:gethostbyaddr).with(anything).and_return(fqdn_hostent)
@plugin.run
expect(@plugin[:fqdn]).to eq("local.dx.internal.cloudapp.net")
end
end
end