require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)

describe "Socket::IPSocket#getaddress" do

  it "returns the IP address of hostname" do
    addr_local = IPSocket.getaddress(SocketSpecs.hostname)
    ["127.0.0.1", "::1"].include?(addr_local).should == true
  end

  it "returns the IP address when passed an IP" do
    IPSocket.getaddress("127.0.0.1").should == "127.0.0.1"
    IPSocket.getaddress("0.0.0.0").should == "0.0.0.0"
  end

  it "raises an error on unknown hostnames" do
    lambda {
      IPSocket.getaddress("rubyspecdoesntexist.fallingsnow.net")
    }.should raise_error(SocketError)
  end

end

require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)

describe "Socket::IPSocket#getaddress" do

  it "returns the IP address of hostname" do
    addr_local = IPSocket.getaddress(SocketSpecs.hostname)
    ["127.0.0.1", "::1"].include?(addr_local).should == true
  end

  it "returns the IP address when passed an IP" do
    IPSocket.getaddress("127.0.0.1").should == "127.0.0.1"
    IPSocket.getaddress("0.0.0.0").should == "0.0.0.0"
  end

  it "raises an error on unknown hostnames" do
    lambda { IPSocket.getaddress("imfakeidontexistanditrynottobeslow.com") }.should raise_error(SocketError)
  end

end

--- 
+++ 
@@ -14,7 +14,9 @@
   end
 
   it "raises an error on unknown hostnames" do
-    lambda { IPSocket.getaddress("imfakeidontexistanditrynottobeslow.com") }.should raise_error(SocketError)
+    lambda {
+      IPSocket.getaddress("rubyspecdoesntexist.fallingsnow.net")
+    }.should raise_error(SocketError)
   end
 
 end
Use a controlled name for testing unknown hostnames

Some ISP intercept unknown domains under .com/.org/.net, so using
somerandomname.com can easily fail.

They don't seem to intercept unknown hostnames under normal domains
though, so I've change us to use rubyspecdoesntexist.fallingsnow.net
because I control fallingsnow.net and I know that there will never be a
DNS entry for this host.
