Sha256: ecdb92b5adc0fa80d80e3f5440bac8568de10dca1860bedffe1f5d9571322edf

Contents?: true

Size: 609 Bytes

Versions: 3

Compression:

Stored size: 609 Bytes

Contents

require 't_helper'
require 'fidius-common/ip-helper'

class IPHelperTest < Test::Unit::TestCase
  def test_get_localhost
    ip = FIDIUS::Common.get_my_ip '127.0.0.1'
    assert_equal '127.0.0.1', ip
  end
  
  def test_get_invalid_host
    assert_raise ArgumentError do
      FIDIUS::Common.get_my_ip '300.0.0.0'
    end
  end
  
  def test_get_google_dns
    begin
      # run `ifconfig` to determine possible addresses?
      ip = FIDIUS::Common.get_my_ip '8.8.8.8'
      assert_not_nil ip
    rescue Errno::ENETUNREACH
      puts "Skipped get_google_dns, since network is not reachable"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fidius-common-0.0.6 test/test_iphelper.rb
fidius-common-0.0.5 test/test_iphelper.rb
fidius-common-0.0.4beta0 test/test_iphelper.rb