faker 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +5 -0
  3. data/README.md +80 -6
  4. data/lib/faker.rb +8 -1
  5. data/lib/faker/address.rb +0 -1
  6. data/lib/faker/avatar.rb +3 -2
  7. data/lib/faker/book.rb +5 -1
  8. data/lib/faker/code.rb +18 -0
  9. data/lib/faker/commerce.rb +3 -3
  10. data/lib/faker/company.rb +9 -1
  11. data/lib/faker/hipster.rb +59 -0
  12. data/lib/faker/id_number.rb +36 -0
  13. data/lib/faker/internet.rb +68 -27
  14. data/lib/faker/number.rb +24 -2
  15. data/lib/faker/placeholdit.rb +20 -0
  16. data/lib/faker/shakespeare.rb +83 -0
  17. data/lib/faker/time.rb +10 -1
  18. data/lib/faker/version.rb +1 -1
  19. data/lib/locales/de.yml +6 -0
  20. data/lib/locales/en-AU.yml +3 -1
  21. data/lib/locales/en-NEP.yml +11 -1
  22. data/lib/locales/en-NZ.yml +25 -0
  23. data/lib/locales/en-SG.yml +31 -0
  24. data/lib/locales/en-US.yml +16 -1
  25. data/lib/locales/en-au-ocker.yml +5 -3
  26. data/lib/locales/en.yml +11 -1
  27. data/lib/locales/es.yml +10 -0
  28. data/lib/locales/fr.yml +6 -1
  29. data/lib/locales/he.yml +25 -0
  30. data/lib/locales/it.yml +6 -6
  31. data/lib/locales/ja.yml +22 -4
  32. data/lib/locales/nb-NO.yml +4 -1
  33. data/lib/locales/pl.yml +1 -1
  34. data/lib/locales/pt-BR.yml +2 -2
  35. data/lib/locales/sk.yml +2 -2
  36. data/lib/locales/zh-CN.yml +2 -0
  37. data/test/test_avatar.rb +9 -5
  38. data/test/test_en_au_locale.rb +24 -0
  39. data/test/test_en_au_ocker_locale.rb +7 -5
  40. data/test/test_en_locale.rb +10 -0
  41. data/test/test_en_nz_locale.rb +33 -0
  42. data/test/test_en_us_locale.rb +10 -0
  43. data/test/test_faker_book.rb +5 -1
  44. data/test/test_faker_code.rb +4 -0
  45. data/test/test_faker_commerce.rb +12 -4
  46. data/test/test_faker_company.rb +5 -1
  47. data/test/test_faker_date.rb +4 -3
  48. data/test/test_faker_hipster.rb +78 -0
  49. data/test/test_faker_internet.rb +36 -3
  50. data/test/test_faker_lorem.rb +3 -3
  51. data/test/test_faker_number.rb +30 -0
  52. data/test/test_faker_shakespeare.rb +53 -0
  53. data/test/test_faker_time.rb +24 -5
  54. data/test/test_placeholdit.rb +92 -0
  55. metadata +19 -2
@@ -4,8 +4,8 @@ ja:
4
4
  postcode: ["###-####"]
5
5
  state: ["北海道", "青森県", "岩手県", "宮城県", "秋田県", "山形県", "福島県", "茨城県", "栃木県", "群馬県", "埼玉県", "千葉県", "東京都", "神奈川県", "新潟県", "富山県", "石川県", "福井県", "山梨県", "長野県", "岐阜県", "静岡県", "愛知県", "三重県", "滋賀県", "京都府", "大阪府", "兵庫県", "奈良県", "和歌山県", "鳥取県", "島根県", "岡山県", "広島県", "山口県", "徳島県", "香川県", "愛媛県", "高知県", "福岡県", "佐賀県", "長崎県", "熊本県", "大分県", "宮崎県", "鹿児島県", "沖縄県"]
6
6
  state_abbr: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47"]
7
- city_prefix: ["北", "東", "西", "南", "新", "", ""]
8
- city_suffix: ["市", "区", "町", "村"]
7
+ city_prefix: ["北", "東", "西", "南", "新", "", "", "小"]
8
+ city_suffix: ["市", "区", "町", "村", "郡"]
9
9
  city:
10
10
  - "#{city_prefix}#{Name.first_name}#{city_suffix}"
11
11
  - "#{Name.first_name}#{city_suffix}"
@@ -14,12 +14,30 @@ ja:
14
14
  street_name:
15
15
  - "#{Name.first_name}#{street_suffix}"
16
16
  - "#{Name.last_name}#{street_suffix}"
17
+
17
18
  phone_number:
18
19
  formats: ['0####-#-####', '0###-##-####', '0##-###-####', '0#-####-####']
20
+
19
21
  cell_phone:
20
22
  formats: ['090-####-####', '080-####-####', '070-####-####']
23
+
21
24
  name:
22
- last_name: ["佐藤", "鈴木", "高橋", "田中", "渡辺", "伊藤", "山本", "中村", "小林", "加藤", "吉田", "山田", "佐々木", "山口", "斎藤", "松本", "井上", "木村", "林", "清水"]
23
- first_name: ["大翔", "蓮", "颯太", "樹", "大和", "陽翔", "陸斗", "太一", "海翔", "蒼空", "", "陽菜", "結愛", "結衣", "", "莉子", "美羽", "結菜", "心愛", "愛菜", "美咲"]
25
+ last_name: ["佐藤", "鈴木", "高橋", "田中", "伊藤", "山本", "渡辺", "中村", "小林", "加藤", "吉田", "山田", "佐々木", "山口", "松本", "井上", "木村", "林", "斎藤", "清水", "山崎", "阿部", "森", "池田", "橋本", "山下", "石川", "中島", "前田", "藤田", "後藤", "小川", "岡田", "村上", "長谷川", "近藤", "石井", "斉藤", "坂本", "遠藤", "藤井", "青木", "福田", "三浦", "西村", "藤原", "太田", "松田", "原田", "岡本", "中野", "中川", "小野", "田村", "竹内", "金子", "中山", "和田", "石田", "工藤", "上田", "原", "森田", "酒井", "横山", "柴田", "宮崎", "宮本", "内田", "高木", "谷口", "安藤", "丸山", "今井", "大野", "高田", "菅原", "河野", "武田", "藤本", "上野", "杉山", "千葉", "村田", "増田", "小島", "小山", "大塚", "平野", "久保", "渡部", "松井", "菊地", "岩崎", "松尾", "佐野", "木下", "野口", "野村", "新井"]
26
+ first_name: ["翔太", "蓮", "翔", "陸", "颯太", "悠斗", "大翔", "翼", "樹", "奏太", "大和", "大輝", "", "隼人", "健太", "大輔", "駿", "陽斗", "優", "陽", "悠人", "誠", "拓海", "仁", "悠太", "悠真", "大地", "健", "遼", "大樹", "諒", "響", "太一", "一郎", "優斗", "", "海斗", "颯", "亮太", "匠", "陽太", "航", "瑛太", "直樹", "空", "光", "太郎", "輝", "一輝", "蒼", "葵", "優那", "優奈", "凛", "陽菜", "", "結衣", "美咲", "楓", "さくら", "遥", "美優", "莉子", "七海", "美月", "結菜", "真央", "花音", "陽子", "舞", "美羽", "優衣", "未来", "彩", "彩乃", "彩花", "優", "智子", "奈々", "千尋", "愛美", "優菜", "杏", "裕子", "芽衣", "綾乃", "琴音", "桜", "恵", "杏奈", "美桜", "優花", "玲奈", "結", "茜", "美穂", "明日香", "愛子", "美緒", "碧"]
24
27
  name:
25
28
  - "#{last_name} #{first_name}"
29
+
30
+ university:
31
+ prefix: ["北海道", "東北", "関東", "中部", "近畿", "中国", "四国", "九州"]
32
+ suffix: ["大学", "医科大学", "芸術大学", "音楽大学", "工業大学"]
33
+ name:
34
+ - "#{Name.last_name}#{University.suffix}"
35
+ - "#{University.prefix}#{Name.last_name}#{University.suffix}"
36
+ - "#{University.prefix}#{Address.city_prefix}#{University.suffix}"
37
+
38
+ company:
39
+ suffix: ["株式会社", "有限会社", "合名会社", "合資会社", "合同会社"]
40
+ category: ["水産", "農林", "鉱業", "建設", "食品", "印刷", "電気", "ガス", "情報", "通信", "運輸", "銀行", "保険"]
41
+ name:
42
+ - "#{Name.last_name}#{category}#{suffix}"
43
+ - "#{suffix}#{Name.last_name}#{category}"
@@ -29,7 +29,7 @@ nb-NO:
29
29
  - "#{Name.last_name} #{suffix}"
30
30
  - "#{Name.last_name}-#{Name.last_name}"
31
31
  - "#{Name.last_name}, #{Name.last_name} og #{Name.last_name}"
32
-
32
+
33
33
  internet:
34
34
  domain_suffix: ["no", "com", "net", "org"]
35
35
 
@@ -50,3 +50,6 @@ nb-NO:
50
50
 
51
51
  phone_number:
52
52
  formats: ["########", "## ## ## ##", "### ## ###", "+47 ## ## ## ##"]
53
+
54
+ cell_phone:
55
+ formats: ["########", "## ## ## ##", "### ## ###", "+47 ## ## ## ##"]
@@ -20,7 +20,7 @@ pl:
20
20
  default_country: [Polska]
21
21
 
22
22
  company:
23
- suffix: [Inc, and Sons, LLC, Group]
23
+ suffix: [S.A., sp. z o.o., sp. j., sp.p., sp. k., S.K.A.]
24
24
  # Buzzword wordlist from http://www.1728.com/buzzword.htm
25
25
  buzzwords:
26
26
  - ["Adaptive", "Advanced", "Ameliorated", "Assimilated", "Automated", "Balanced", "Business-focused", "Centralized", "Cloned", "Compatible", "Configurable", "Cross-group", "Cross-platform", "Customer-focused", "Customizable", "Decentralized", "De-engineered", "Devolved", "Digitized", "Distributed", "Diverse", "Down-sized", "Enhanced", "Enterprise-wide", "Ergonomic", "Exclusive", "Expanded", "Extended", "Face to face", "Focused", "Front-line", "Fully-configurable", "Function-based", "Fundamental", "Future-proofed", "Grass-roots", "Horizontal", "Implemented", "Innovative", "Integrated", "Intuitive", "Inverse", "Managed", "Mandatory", "Monitored", "Multi-channelled", "Multi-lateral", "Multi-layered", "Multi-tiered", "Networked", "Object-based", "Open-architected", "Open-source", "Operative", "Optimized", "Optional", "Organic", "Organized", "Persevering", "Persistent", "Phased", "Polarised", "Pre-emptive", "Proactive", "Profit-focused", "Profound", "Programmable", "Progressive", "Public-key", "Quality-focused", "Reactive", "Realigned", "Re-contextualized", "Re-engineered", "Reduced", "Reverse-engineered", "Right-sized", "Robust", "Seamless", "Secured", "Self-enabling", "Sharable", "Stand-alone", "Streamlined", "Switchable", "Synchronised", "Synergistic", "Synergized", "Team-oriented", "Total", "Triple-buffered", "Universal", "Up-sized", "Upgradable", "User-centric", "User-friendly", "Versatile", "Virtual", "Visionary", "Vision-oriented"]
@@ -24,7 +24,7 @@ pt-BR:
24
24
  "Suécia", "Suíça", "Síria", "Taiwan", "Tajiquistão", "Tanzânia", "Tailândia", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidá e Tobago", "Tunísia",
25
25
  "Turquia", "Turcomenistão", "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ucrânia", "Emirados Árabes Unidos", "Reino Unido", "Estados Unidos da América",
26
26
  "Estados Unidos das Ilhas Virgens", "Uruguai", "Uzbequistão", "Vanuatu", "Venezuela", "Vietnã", "Wallis and Futuna", "Sahara", "Yemen", "Zâmbia", "Zimbábue"]
27
- building_number: ["#####", "####", "###"]
27
+ building_number: ["#####", "####", "###", "s/n"]
28
28
  street_suffix: ["Rua", "Avenida", "Travessa", "Ponte", "Alameda", "Marginal", "Viela", "Rodovia"]
29
29
  secondary_address: ["Apto. ###", "Sobrado ##", "Casa #", "Lote ##", "Quadra ##"]
30
30
  # Though these are US-specific, they are here (in the default locale) for backwards compatibility
@@ -34,7 +34,7 @@ pt-BR:
34
34
  default_country: [Brasil]
35
35
 
36
36
  company:
37
- suffix: ["S.A.", "LTDA", "e Associados", "Comércio"]
37
+ suffix: ["S.A.", "LTDA", "e Associados", "Comércio", "EIRELI"]
38
38
  name:
39
39
  - "#{Name.last_name} #{suffix}"
40
40
  - "#{Name.last_name}-#{Name.last_name}"
@@ -7,8 +7,8 @@ sk:
7
7
  building_number: ['#', '##', '###']
8
8
  secondary_address: ['Apt. ###', 'Suite ###']
9
9
  postcode: ['#####', '### ##', '## ###']
10
- state: []
11
- state_abbr: []
10
+ state: ['Bratislavský', 'Trnavský', 'Trenčiansky', 'Nitriansky', 'Žilinský', 'Banskobystrický', 'Prešovský', 'Košický']
11
+ state_abbr: ['BA', 'TT', 'TN', 'NR', 'ZA', 'BB', 'PO', 'KI']
12
12
  time_zone: [Pacific/Midway, Pacific/Pago_Pago, Pacific/Honolulu, America/Juneau, America/Los_Angeles, America/Tijuana, America/Denver, America/Phoenix, America/Chihuahua, America/Mazatlan, America/Chicago, America/Regina, America/Mexico_City, America/Mexico_City, America/Monterrey, America/Guatemala, America/New_York, America/Indiana/Indianapolis, America/Bogota, America/Lima, America/Lima, America/Halifax, America/Caracas, America/La_Paz, America/Santiago, America/St_Johns, America/Sao_Paulo, America/Argentina/Buenos_Aires, America/Guyana, America/Godthab, Atlantic/South_Georgia, Atlantic/Azores, Atlantic/Cape_Verde, Europe/Dublin, Europe/London, Europe/Lisbon, Europe/London, Africa/Casablanca, Africa/Monrovia, Etc/UTC, Europe/Belgrade, Europe/Bratislava, Europe/Budapest, Europe/Ljubljana, Europe/Prague, Europe/Sarajevo, Europe/Skopje, Europe/Warsaw, Europe/Zagreb, Europe/Brussels, Europe/Copenhagen, Europe/Madrid, Europe/Paris, Europe/Amsterdam, Europe/Berlin, Europe/Berlin, Europe/Rome, Europe/Stockholm, Europe/Vienna, Africa/Algiers, Europe/Bucharest, Africa/Cairo, Europe/Helsinki, Europe/Kiev, Europe/Riga, Europe/Sofia, Europe/Tallinn, Europe/Vilnius, Europe/Athens, Europe/Istanbul, Europe/Minsk, Asia/Jerusalem, Africa/Harare, Africa/Johannesburg, Europe/Moscow, Europe/Moscow, Europe/Moscow, Asia/Kuwait, Asia/Riyadh, Africa/Nairobi, Asia/Baghdad, Asia/Tehran, Asia/Muscat, Asia/Muscat, Asia/Baku, Asia/Tbilisi, Asia/Yerevan, Asia/Kabul, Asia/Yekaterinburg, Asia/Karachi, Asia/Karachi, Asia/Tashkent, Asia/Kolkata, Asia/Kolkata, Asia/Kolkata, Asia/Kolkata, Asia/Kathmandu, Asia/Dhaka, Asia/Dhaka, Asia/Colombo, Asia/Almaty, Asia/Novosibirsk, Asia/Rangoon, Asia/Bangkok, Asia/Bangkok, Asia/Jakarta, Asia/Krasnoyarsk, Asia/Shanghai, Asia/Chongqing, Asia/Hong_Kong, Asia/Urumqi, Asia/Kuala_Lumpur, Asia/Singapore, Asia/Taipei, Australia/Perth, Asia/Irkutsk, Asia/Ulaanbaatar, Asia/Seoul, Asia/Tokyo, Asia/Tokyo, Asia/Tokyo, Asia/Yakutsk, Australia/Darwin, Australia/Adelaide, Australia/Melbourne, Australia/Melbourne, Australia/Sydney, Australia/Brisbane, Australia/Hobart, Asia/Vladivostok, Pacific/Guam, Pacific/Port_Moresby, Asia/Magadan, Asia/Magadan, Pacific/Noumea, Pacific/Fiji, Asia/Kamchatka, Pacific/Majuro, Pacific/Auckland, Pacific/Auckland, Pacific/Tongatapu, Pacific/Fakaofo, Pacific/Apia]
13
13
  city_name: [Bánovce nad Bebravou, Banská Bystrica, Banská Štiavnica, Bardejov, Bratislava I, Bratislava II, Bratislava III, Bratislava IV, Bratislava V, Brezno, Bytča, Čadca, Detva, Dolný Kubín, Dunajská Streda, Galanta, Gelnica, Hlohovec, Humenné, Ilava, Kežmarok, Komárno, Košice I, Košice II, Košice III, Košice IV, Košice-okolie, Krupina, Kysucké Nové Mesto, Levice, Levoča, Liptovský Mikuláš, Lučenec, Malacky, Martin, Medzilaborce, Michalovce, Myjava, Námestovo, Nitra, Nové Mesto n.Váhom, Nové Zámky, Partizánske, Pezinok, Piešťany, Poltár, Poprad, Považská Bystrica, Prešov, Prievidza, Púchov, Revúca, Rimavská Sobota, Rožňava, Ružomberok, Sabinov, Šaľa, Senec, Senica, Skalica, Snina, Sobrance, Spišská Nová Ves, Stará Ľubovňa, Stropkov, Svidník, Topoľčany, Trebišov, Trenčín, Trnava, Turčianske Teplice, Tvrdošín, Veľký Krtíš, Vranov nad Topľou, Žarnovica, Žiar nad Hronom, Žilina, Zlaté Moravce, Zvolen]
14
14
  city:
@@ -25,3 +25,5 @@ zh-CN:
25
25
  - "#{last_name}#{first_name}"
26
26
  phone_number:
27
27
  formats: ['###-########', '####-########', '###########']
28
+ cell_phone:
29
+ formats: ['1##########']
@@ -6,15 +6,15 @@ class TestFakerAvatar < Test::Unit::TestCase
6
6
  end
7
7
 
8
8
  def test_avatar
9
- assert @tester.image.match(/http:\/\/robohash\.org\/(.+)\.png/)[1] != nil
9
+ assert @tester.image.match(/https:\/\/robohash\.org\/(.+)\.png/)[1] != nil
10
10
  end
11
11
 
12
12
  def test_avatar_with_param
13
- assert @tester.image('faker').match(/http:\/\/robohash\.org\/(.+)\.png/)[1] == 'faker'
13
+ assert @tester.image('faker').match(/https:\/\/robohash\.org\/(.+)\.png/)[1] == 'faker'
14
14
  end
15
15
 
16
16
  def test_avatar_with_correct_size
17
- assert @tester.image('faker', '150x320').match(/http:\/\/robohash\.org\/faker\.png\?size=(.+)&.*/)[1] == '150x320'
17
+ assert @tester.image('faker', '150x320').match(/https:\/\/robohash\.org\/faker\.png\?size=(.+)&.*/)[1] == '150x320'
18
18
  end
19
19
 
20
20
  def test_avatar_with_incorrect_size
@@ -24,7 +24,7 @@ class TestFakerAvatar < Test::Unit::TestCase
24
24
  end
25
25
 
26
26
  def test_avatar_with_supported_format
27
- assert @tester.image('faker', '300x300', 'jpg').match(/http:\/\/robohash\.org\/faker\.jpg/)
27
+ assert @tester.image('faker', '300x300', 'jpg').match(/https:\/\/robohash\.org\/faker\.jpg/)
28
28
  end
29
29
 
30
30
  def test_avatar_with_incorrect_format
@@ -34,6 +34,10 @@ class TestFakerAvatar < Test::Unit::TestCase
34
34
  end
35
35
 
36
36
  def test_avatar_with_set
37
- assert @tester.image('faker', '300x300', 'jpg', 'set2').match(/http:\/\/robohash\.org\/faker\.jpg.*set=set2/)
37
+ assert @tester.image('faker', '300x300', 'jpg', 'set2').match(/https:\/\/robohash\.org\/faker\.jpg.*set=set2/)
38
+ end
39
+
40
+ def test_avatar_with_bgset
41
+ assert @tester.image('faker', '300x300', 'jpg', 'set1', 'bg1').match(/https:\/\/robohash\.org\/faker\.jpg.*bgset=bg1/)
38
42
  end
39
43
  end
@@ -0,0 +1,24 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
+
3
+ class TestEnAuLocale < Test::Unit::TestCase
4
+ def setup
5
+ Faker::Config.locale = 'en-AU'
6
+ end
7
+
8
+ def teardown
9
+ Faker::Config.locale = nil
10
+ end
11
+
12
+ def test_au_methods_with_en_au_locale
13
+ assert Faker::Name.first_name.is_a? String
14
+ assert Faker::Name.last_name.is_a? String
15
+ assert Faker::Address.street_name.is_a? String
16
+ assert Faker::Address.city.is_a? String
17
+ end
18
+
19
+ def test_aussie_mobiles_start_with_04
20
+ mobile = Faker::PhoneNumber.cell_phone.gsub(/\D/,'')
21
+ assert_equal '0', mobile[0]
22
+ assert_equal '4', mobile[1]
23
+ end
24
+ end
@@ -1,8 +1,8 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
2
 
3
- class TestEnUsLocale < Test::Unit::TestCase
3
+ class TestEnAuOckerLocale < Test::Unit::TestCase
4
4
  def setup
5
- Faker::Config.locale = nil
5
+ Faker::Config.locale = 'en-au-ocker'
6
6
  end
7
7
 
8
8
  def teardown
@@ -10,14 +10,16 @@ class TestEnUsLocale < Test::Unit::TestCase
10
10
  end
11
11
 
12
12
  def test_au_ocker_methods_with_en_au_ocker_locale
13
- Faker::Config.locale = 'en-au-ocker'
14
-
15
13
  assert Faker::Name.first_name.is_a? String
16
14
  assert Faker::Name.last_name.is_a? String
17
15
  assert Faker::Name.ocker_first_name.is_a? String
18
16
  assert Faker::Address.street_name.is_a? String
19
17
  assert Faker::Address.city.is_a? String
20
- assert Faker::Address.region.is_a? String
21
18
  end
22
19
 
20
+ def test_aussie_mobiles_start_with_04
21
+ mobile = Faker::PhoneNumber.cell_phone.gsub(/\D/,'')
22
+ assert_equal '0', mobile[0]
23
+ assert_equal '4', mobile[1]
24
+ end
23
25
  end
@@ -22,4 +22,14 @@ class TesetEnLocale < Test::Unit::TestCase
22
22
  assert_match(expected, Faker::Address.zip_code)
23
23
  end
24
24
 
25
+ def test_valid_id_number
26
+ id_num = Faker::IDNumber.valid
27
+ assert Faker::IDNumber::INVALID_SSN.none? { |regex| id_num =~ regex }
28
+ end
29
+
30
+ def test_invalid_id_number
31
+ id_num = Faker::IDNumber.invalid
32
+ assert Faker::IDNumber::INVALID_SSN.any? { |regex| id_num =~ regex }
33
+ end
34
+
25
35
  end
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
+
3
+ class TestEnNzLocale < Test::Unit::TestCase
4
+ def setup
5
+ Faker::Config.locale = 'en-NZ'
6
+ end
7
+
8
+ def teardown
9
+ Faker::Config.locale = nil
10
+ end
11
+
12
+ def test_nz_methods_with_en_nz_locale
13
+ assert Faker::Name.first_name.is_a? String
14
+ assert Faker::Name.last_name.is_a? String
15
+ assert Faker::Address.street_name.is_a? String
16
+ assert Faker::Address.city.is_a? String
17
+ end
18
+
19
+ def test_nz_cellphones_start_with_02
20
+ cellphone = Faker::PhoneNumber.cell_phone.gsub(/\D/,'')
21
+ assert_equal '0', cellphone[0]
22
+ assert_equal '2', cellphone[1]
23
+ end
24
+
25
+ def test_nz_is_default_country
26
+ assert_equal 'New Zealand', Faker::Address.default_country
27
+ end
28
+
29
+ def test_regions_with_en_nz_locale
30
+ assert Faker::Address.region.is_a? String
31
+ assert Faker::Address.region_abbr.is_a? String
32
+ end
33
+ end
@@ -76,4 +76,14 @@ class TesetEnUsLocale < Test::Unit::TestCase
76
76
  assert_match(expected, Faker::Address.zip_code(state_abbr))
77
77
 
78
78
  end
79
+
80
+ def test_valid_id_number
81
+ id_num = Faker::IDNumber.valid
82
+ assert Faker::IDNumber::INVALID_SSN.none? { |regex| id_num =~ regex }
83
+ end
84
+
85
+ def test_invalid_id_number
86
+ id_num = Faker::IDNumber.invalid
87
+ assert Faker::IDNumber::INVALID_SSN.any? { |regex| id_num =~ regex }
88
+ end
79
89
  end
@@ -15,6 +15,10 @@ class TestFakerBook < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  def test_publisher
18
- assert @tester.author.match(/(\w+\.? ?){2,3}/)
18
+ assert @tester.publisher.match(/(\w+\.? ?){2,3}/)
19
+ end
20
+
21
+ def test_genre
22
+ assert @tester.genre.match(/(\w+\.? ?){2,3}/)
19
23
  end
20
24
  end
@@ -28,4 +28,8 @@ class TestFakerCode < Test::Unit::TestCase
28
28
  def test_rut
29
29
  assert @tester.rut.match(/^\d{1,8}-(\d|k)$/)
30
30
  end
31
+
32
+ def test_nric
33
+ assert @tester.nric.match(/^(S|T)\d{7}[A-JZ]$/)
34
+ end
31
35
  end
@@ -5,15 +5,15 @@ class TestFakerCommerce < Test::Unit::TestCase
5
5
  def setup
6
6
  @tester = Faker::Commerce
7
7
  end
8
-
8
+
9
9
  def test_color
10
10
  assert @tester.color.match(/[a-z]+\.?/)
11
11
  end
12
-
12
+
13
13
  def test_department
14
14
  assert @tester.department.match(/[A-Z][a-z]+\.?/)
15
15
  end
16
-
16
+
17
17
  def test_single_department_should_not_contain_separators
18
18
  assert_match(/\A[A-Za-z]+\z/, @tester.department(1))
19
19
  end
@@ -65,9 +65,17 @@ class TestFakerCommerce < Test::Unit::TestCase
65
65
 
66
66
  def test_price
67
67
  assert_includes 0..100, @tester.price
68
+ assert_instance_of Float, @tester.price(5..6)
69
+ assert_includes 5..6, @tester.price(5..6)
70
+ assert_includes 990...1000, @tester.price(990...1000)
71
+ end
72
+
73
+ def test_price_with_srand
74
+ srand(12345)
75
+ assert_equal 92.96, @tester.price
68
76
  end
69
77
 
70
78
  def test_price_is_float
71
79
  assert @tester.price.is_a? Float
72
80
  end
73
- end
81
+ end
@@ -14,7 +14,7 @@ class TestFakerCompany < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  def test_logo
17
- assert @tester.logo.match(%r{http://pigment.github.io/fake-logos/logos/medium/color/\d+\.png})
17
+ assert @tester.logo.match(%r{https://pigment.github.io/fake-logos/logos/medium/color/\d+\.png})
18
18
  end
19
19
 
20
20
  def test_buzzword
@@ -27,4 +27,8 @@ class TestFakerCompany < Test::Unit::TestCase
27
27
  assert org_no[9] == @tester.send(:luhn_algorithm, org_no[0..8]).to_s
28
28
  end
29
29
 
30
+ def test_profession
31
+ assert @tester.profession.match(/[a-z ]+\.?/)
32
+ end
33
+
30
34
  end
@@ -58,10 +58,11 @@ class TestFakerDate < Test::Unit::TestCase
58
58
  date_min = Date.new(t.year - min, t.month, t.day)
59
59
  date_max = Date.new(t.year - max, t.month, t.day)
60
60
  birthday = @tester.birthday(min, max)
61
- assert birthday > date_max, "Expect > \"#{date_max}\", but got #{birthday}"
62
- assert birthday < date_min, "Expect > \"#{date_max}\", but got #{birthday}"
61
+ assert birthday >= date_max, "Expect > \"#{date_max}\", but got #{birthday}"
62
+ assert birthday <= date_min, "Expect > \"#{date_max}\", but got #{birthday}"
63
63
  end
64
64
  end
65
+
65
66
  def test_default_birthday
66
67
  min = 10
67
68
  max = 65
@@ -70,7 +71,7 @@ class TestFakerDate < Test::Unit::TestCase
70
71
  date_min = Date.new(t.year - min, t.month, t.day)
71
72
  date_max = Date.new(t.year - max, t.month, t.day)
72
73
  birthday = @tester.birthday
73
- assert birthday > date_max, "Expect > \"#{date_max}\", but got #{birthday}"
74
+ assert birthday >= date_max, "Expect > \"#{date_max}\", but got #{birthday}"
74
75
  assert birthday < date_min, "Expect > \"#{date_max}\", but got #{birthday}"
75
76
  end
76
77
  end
@@ -0,0 +1,78 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestFakerHipster < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @tester = Faker::Hipster
7
+ @standard_wordlist = I18n.translate('faker.hipster.words')
8
+ @complete_wordlist =
9
+ @standard_wordlist + I18n.translate('faker.lorem.words')
10
+ end
11
+
12
+ # Words delivered by a standard request should be on the standard wordlist.
13
+ def test_words
14
+ @words = @tester.words(1000)
15
+ @words.each { |w| assert @standard_wordlist.include?(w) }
16
+ end
17
+
18
+ # Words should not return any word with spaces
19
+ def test_words_without_spaces
20
+ @words = @tester.words(1000)
21
+ @words.each { |w| assert !w.match(/\s/) }
22
+ end
23
+
24
+ # Words requested from the supplemental list should all be in that list.
25
+ def test_supplemental_words
26
+ @words = @tester.words(10000, true)
27
+ @words.each { |w| assert @complete_wordlist.include?(w) }
28
+ end
29
+
30
+ # Faker::Hipster.word generates random word from standart wordlist
31
+ def test_word
32
+ @tester = Faker::Hipster
33
+ @standard_wordlist = I18n.translate('faker.hipster.words')
34
+ 1000.times { assert @standard_wordlist.include?(@tester.word) }
35
+ end
36
+
37
+ # Word should not return any word with spaces
38
+ def test_word_without_spaces
39
+ @tester = Faker::Hipster
40
+ 1000.times { assert !@tester.word.match(/\s/) }
41
+ end
42
+
43
+ def test_exact_count_param
44
+ assert(@tester.words(2).length == 2)
45
+ assert(@tester.sentences(2).length == 2)
46
+ assert(@tester.paragraphs(2).length == 2)
47
+ end
48
+
49
+ def test_range_count_param
50
+ ws = @tester.words(2..5)
51
+ ss = @tester.sentences(2..5)
52
+ ps = @tester.paragraphs(2..5)
53
+
54
+ assert(2 <= ws.length && ws.length <= 5)
55
+ assert(2 <= ss.length && ss.length <= 5)
56
+ assert(2 <= ps.length && ps.length <= 5)
57
+ end
58
+
59
+ def test_array_count_param
60
+ ws = @tester.words([1,4])
61
+ ss = @tester.sentences([1,4])
62
+ ps = @tester.paragraphs([1,4])
63
+
64
+ assert(ws.length == 1 || ws.length == 4)
65
+ assert(ss.length == 1 || ss.length == 4)
66
+ assert(ps.length == 1 || ps.length == 4)
67
+ end
68
+
69
+ def test_words_with_large_count_params
70
+ exact = @tester.words(500)
71
+ range = @tester.words(250..500)
72
+ array = @tester.words([250, 500])
73
+
74
+ assert(exact.length == 500)
75
+ assert(250 <= range.length && range.length <= 500)
76
+ assert(array.length == 250 || array.length == 500)
77
+ end
78
+ end