Add test coverage for darwin host configured addresses capability

This commit is contained in:
Chris Roberts 2017-12-20 16:52:54 -08:00
parent 98ce718e63
commit e12e2d5374
1 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,31 @@
require_relative "../../../../base"
require_relative "../../../../../../plugins/hosts/darwin/cap/configured_ip_addresses"
describe VagrantPlugins::HostDarwin::Cap::ConfiguredIPAddresses do
let(:subject){ VagrantPlugins::HostDarwin::Cap::ConfiguredIPAddresses }
let(:interfaces){ ["192.168.1.2"] }
before{ allow(Socket).to receive(:getifaddrs).and_return(
interfaces.map{|i| double(:socket, addr: Addrinfo.ip(i))}) }
it "should get list of available addresses" do
expect(subject.configured_ip_addresses(nil)).to eq(["192.168.1.2"])
end
context "with loopback address" do
let(:interfaces){ ["192.168.1.2", "127.0.0.1"] }
it "should not include loopback address" do
expect(subject.configured_ip_addresses(nil)).not_to include(["127.0.0.1"])
end
end
context "with IPv6 address" do
let(:interfaces){ ["192.168.1.2", "2001:200:dff:fff1:216:3eff:feb1:44d7"] }
it "should not include IPv6 address" do
expect(subject.configured_ip_addresses(nil)).not_to include(["2001:200:dff:fff1:216:3eff:feb1:44d7"])
end
end
end