Sha256: 62c975f82d8967f5559cc2ba96204d9a5d8ffb57445b6764f0a143874a1a584e

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'

class TestFakerInternet < Test::Unit::TestCase

  def setup
    @tester = Faker::Internet
  end
  
  def test_email
    assert @tester.email.match(/.+@.+\.\w+/)
  end
  
  def test_free_email
    assert @tester.free_email.match(/.+@(gmail|hotmail|yahoo)\.com/)
  end
  
  def test_user_name
    assert @tester.user_name.match(/[a-z]+((_|\.)[a-z]+)?/)
  end
  
  def test_user_name_with_arg
    assert @tester.user_name('bo peep').match(/(bo(_|\.)peep|peep(_|\.)bo)/)
  end
  
  def test_domain_name
    assert @tester.domain_name.match(/\w+\.\w+/)
  end
  
  def test_domain_word
    assert @tester.domain_word.match(/^\w+$/)
  end
  
  def test_domain_suffix
    assert @tester.domain_suffix.match(/^\w+(\.\w+)?/)
  end

  def test_ip_v4_address
    assert_equal 3, @tester.ip_v4_address.count('.')

    1000.times do
      assert @tester.ip_v4_address.split('.').map{|octet| octet.to_i}.max <= 255
    end
  end

  def test_ip_v6_address
    assert_equal 7, @tester.ip_v6_address.count(':')

    1000.times do
      assert @tester.ip_v6_address.split('.').map{|h| "0x#{h}".hex}.max <= 65535
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
faker-fakeme-0.10.0 test/test_faker_internet.rb
faker-fakeme-0.9.9 test/test_faker_internet.rb
faker-fakeme-0.9.8 test/test_faker_internet.rb
faker-fakeme-0.9.7 test/test_faker_internet.rb
faker-fakeme-0.9.6 test/test_faker_internet.rb
faker-fakeme-0.1.1 test/test_faker_internet.rb
faker-fakeme-0.9.5 test/test_faker_internet.rb