title: How do I mock a method of 'Socket' using MiniTest?
body: <p>I have a short method which takes no arguments and returns a hash of local IP addresses in string form as keys with true as the value:</p>
  
  <pre><code>def self.local_ips
    # puts 'Getting ip addresses for this computer...'
    local_ips = {}
    Socket.ip_address_list.each do |address|
      ip_string = address.ip_address
      ip_string.sub!(/\%.*$/, '') # Removes interface from end of some IP's
      local_ips[IPAddr.new(ip_string).to_s] = true
    end
    return local_ips
  end
  </code></pre>
  
  <p>This works correctly, correctly being defined by it is working as expected, but I would like to have a spec which tests this method. The problem is, <code>Socket.ip_address_list</code> will return differently on each machine it is on. I was wondering if there was a way while using MiniTest to mock the response of <code>Socket.ip_address_list</code> so that the method can be tested on any machine without fear of failure due to differences related to the local machine.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks!</p>