diff options
Diffstat (limited to 'spec/unit/mixin/network_helper_spec.rb')
-rw-r--r-- | spec/unit/mixin/network_helper_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/unit/mixin/network_helper_spec.rb b/spec/unit/mixin/network_helper_spec.rb index a57af17f..4a2c4cbf 100644 --- a/spec/unit/mixin/network_helper_spec.rb +++ b/spec/unit/mixin/network_helper_spec.rb @@ -27,4 +27,16 @@ describe Ohai::Mixin::NetworkHelper, "Network Helper Mixin" do expect(mixin.hex_to_dec_netmask("ffff0000")).to eq("255.255.0.0") end end + + describe "canonicalize hostname" do + # this is a brittle test deliberately intended to discourage modifying this API + # (see the node in the code on the necessity of manual testing) + it "uses the correct ruby API" do + hostname = "broken.example.org" + addrinfo = instance_double(Addrinfo) + expect(Addrinfo).to receive(:getaddrinfo).with(hostname, nil, nil, nil, nil, Socket::AI_CANONNAME).and_return([addrinfo]) + expect(addrinfo).to receive(:canonname).and_return(hostname) + expect(mixin.canonicalize_hostname(hostname)).to eql(hostname) + end + end end |