ffaker 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (320) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +34 -0
  3. data/README.md +4 -0
  4. data/REFERENCE.md +1153 -800
  5. data/Rakefile +23 -24
  6. data/ffaker.gemspec +12 -420
  7. data/lib/ffaker.rb +47 -7
  8. data/lib/ffaker/address.rb +11 -11
  9. data/lib/ffaker/address_au.rb +60 -60
  10. data/lib/ffaker/address_br.rb +5 -5
  11. data/lib/ffaker/address_ca.rb +7 -7
  12. data/lib/ffaker/address_ch.rb +1 -2
  13. data/lib/ffaker/address_ch_de.rb +1 -1
  14. data/lib/ffaker/address_ch_fr.rb +1 -1
  15. data/lib/ffaker/address_ch_it.rb +1 -1
  16. data/lib/ffaker/address_da.rb +5 -5
  17. data/lib/ffaker/address_de.rb +16 -12
  18. data/lib/ffaker/address_fi.rb +7 -8
  19. data/lib/ffaker/address_fr.rb +13 -13
  20. data/lib/ffaker/address_gr.rb +40 -0
  21. data/lib/ffaker/address_in.rb +12 -12
  22. data/lib/ffaker/address_kr.rb +87 -0
  23. data/lib/ffaker/address_mx.rb +409 -409
  24. data/lib/ffaker/address_nl.rb +17 -13
  25. data/lib/ffaker/address_ru.rb +6 -6
  26. data/lib/ffaker/address_se.rb +7 -8
  27. data/lib/ffaker/address_sn.rb +3 -3
  28. data/lib/ffaker/address_ua.rb +8 -8
  29. data/lib/ffaker/address_uk.rb +5 -5
  30. data/lib/ffaker/address_us.rb +9 -9
  31. data/lib/ffaker/airline.rb +16 -0
  32. data/lib/ffaker/avatar.rb +3 -3
  33. data/lib/ffaker/aws.rb +24 -0
  34. data/lib/ffaker/bacon_ipsum.rb +2 -2
  35. data/lib/ffaker/book.rb +45 -0
  36. data/lib/ffaker/boolean.rb +2 -2
  37. data/lib/ffaker/cheesy_lingo.rb +15 -12
  38. data/lib/ffaker/color.rb +54 -1
  39. data/lib/ffaker/color_ua.rb +1 -1
  40. data/lib/ffaker/company.rb +13 -11
  41. data/lib/ffaker/company_cn.rb +23 -0
  42. data/lib/ffaker/company_it.rb +4 -4
  43. data/lib/ffaker/company_se.rb +2 -2
  44. data/lib/ffaker/conference.rb +1 -1
  45. data/lib/ffaker/courses.rb +2 -3
  46. data/lib/ffaker/currency.rb +2 -2
  47. data/lib/ffaker/data/address_gr/city +79 -0
  48. data/lib/ffaker/data/address_gr/region +13 -0
  49. data/lib/ffaker/data/address_gr/street +100 -0
  50. data/lib/ffaker/data/address_kr/boroughs +29 -0
  51. data/lib/ffaker/data/address_kr/cities +51 -0
  52. data/lib/ffaker/data/airline/codes_list +209 -0
  53. data/lib/ffaker/data/airline/names_list +206 -0
  54. data/lib/ffaker/data/aws/ec2_instance_type +59 -0
  55. data/lib/ffaker/data/aws/ec2_reserved_instance_tenancy +3 -0
  56. data/lib/ffaker/data/aws/ec2_reserved_offering_type +6 -0
  57. data/lib/ffaker/data/aws/ec2_reserved_product_description +14 -0
  58. data/lib/ffaker/data/book/adj_and_adv +20 -0
  59. data/lib/ffaker/data/book/genres +369 -0
  60. data/lib/ffaker/data/book/nouns +36 -0
  61. data/lib/ffaker/data/book/prefixes +17 -0
  62. data/lib/ffaker/data/color/names_list +128 -0
  63. data/lib/ffaker/data/education/degree_prefix +274 -0
  64. data/lib/ffaker/data/education/degree_short_prefix +19 -0
  65. data/lib/ffaker/data/job_br/job_nouns +52 -0
  66. data/lib/ffaker/data/job_vn/job_nouns +191 -0
  67. data/lib/ffaker/data/lorem_ja/characters +101 -0
  68. data/lib/ffaker/data/lorem_ja/sentences +30 -0
  69. data/lib/ffaker/data/lorem_ja/sentences_end +21 -0
  70. data/lib/ffaker/data/lorem_ja/words +81 -0
  71. data/lib/ffaker/data/name/first_names_female +4275 -0
  72. data/lib/ffaker/data/name/first_names_male +1219 -0
  73. data/lib/ffaker/data/name_br/first_names_female +1068 -0
  74. data/lib/ffaker/data/name_br/first_names_male +607 -0
  75. data/lib/ffaker/data/name_br/last_names +52 -0
  76. data/lib/ffaker/data/name_gr/female_first_names +80 -0
  77. data/lib/ffaker/data/name_gr/female_last_names +45 -0
  78. data/lib/ffaker/data/name_gr/male_first_names +90 -0
  79. data/lib/ffaker/data/name_gr/male_last_names +57 -0
  80. data/lib/ffaker/data/name_kh/first_names +64 -0
  81. data/lib/ffaker/data/name_kh/last_names +71 -0
  82. data/lib/ffaker/data/name_kh/nick_names +30 -0
  83. data/lib/ffaker/data/name_then/first_names +292 -0
  84. data/lib/ffaker/data/name_then/last_names +63 -0
  85. data/lib/ffaker/data/name_then/nick_names +30 -0
  86. data/lib/ffaker/data/phone_number/phone_calling_code +205 -0
  87. data/lib/ffaker/data/sport/names +57 -24
  88. data/lib/ffaker/data/tweet/hashtag +58 -0
  89. data/lib/ffaker/data/youtube/video_ids +50 -0
  90. data/lib/ffaker/dizzle_ipsum.rb +2 -2
  91. data/lib/ffaker/education.rb +17 -16
  92. data/lib/ffaker/food.rb +5 -6
  93. data/lib/ffaker/gender.rb +4 -4
  94. data/lib/ffaker/gender_br.rb +17 -0
  95. data/lib/ffaker/gender_cn.rb +4 -4
  96. data/lib/ffaker/gender_kr.rb +4 -4
  97. data/lib/ffaker/geolocation.rb +26 -26
  98. data/lib/ffaker/healthcare_ipsum.rb +2 -2
  99. data/lib/ffaker/hipster_ipsum.rb +2 -2
  100. data/lib/ffaker/html_ipsum.rb +101 -81
  101. data/lib/ffaker/identification.rb +4 -4
  102. data/lib/ffaker/identification_br.rb +84 -0
  103. data/lib/ffaker/identification_es.rb +2 -2
  104. data/lib/ffaker/identification_es_cl.rb +7 -5
  105. data/lib/ffaker/identification_es_co.rb +9 -10
  106. data/lib/ffaker/identification_kr.rb +3 -4
  107. data/lib/ffaker/identification_mx.rb +27 -11
  108. data/lib/ffaker/internet.rb +26 -23
  109. data/lib/ffaker/internet_se.rb +21 -21
  110. data/lib/ffaker/job.rb +1 -1
  111. data/lib/ffaker/job_br.rb +12 -0
  112. data/lib/ffaker/job_cn.rb +1 -1
  113. data/lib/ffaker/job_fr.rb +3 -3
  114. data/lib/ffaker/job_ja.rb +2 -1
  115. data/lib/ffaker/job_kr.rb +1 -1
  116. data/lib/ffaker/job_vn.rb +13 -0
  117. data/lib/ffaker/locale.rb +2 -3
  118. data/lib/ffaker/lorem.rb +5 -5
  119. data/lib/ffaker/lorem_ar.rb +4 -4
  120. data/lib/ffaker/lorem_cn.rb +3 -3
  121. data/lib/ffaker/lorem_fr.rb +4 -4
  122. data/lib/ffaker/lorem_ja.rb +40 -0
  123. data/lib/ffaker/lorem_kr.rb +4 -4
  124. data/lib/ffaker/lorem_ua.rb +8 -11
  125. data/lib/ffaker/movie.rb +18 -20
  126. data/lib/ffaker/music.rb +4 -4
  127. data/lib/ffaker/name.rb +100 -11
  128. data/lib/ffaker/name_br.rb +37 -6
  129. data/lib/ffaker/name_cn.rb +2 -2
  130. data/lib/ffaker/name_cs.rb +10 -10
  131. data/lib/ffaker/name_da.rb +6 -6
  132. data/lib/ffaker/name_de.rb +5 -5
  133. data/lib/ffaker/name_fr.rb +4 -4
  134. data/lib/ffaker/name_ga.rb +4 -5
  135. data/lib/ffaker/name_gr.rb +60 -0
  136. data/lib/ffaker/name_it.rb +4 -4
  137. data/lib/ffaker/name_ja.rb +3 -3
  138. data/lib/ffaker/name_kh.rb +22 -0
  139. data/lib/ffaker/name_kr.rb +3 -3
  140. data/lib/ffaker/name_mx.rb +14 -14
  141. data/lib/ffaker/name_nb.rb +5 -5
  142. data/lib/ffaker/name_nl.rb +7 -7
  143. data/lib/ffaker/name_ph.rb +2 -2
  144. data/lib/ffaker/name_ru.rb +7 -8
  145. data/lib/ffaker/name_se.rb +5 -5
  146. data/lib/ffaker/name_sn.rb +23 -23
  147. data/lib/ffaker/name_th.rb +3 -3
  148. data/lib/ffaker/name_th_en.rb +26 -0
  149. data/lib/ffaker/name_ua.rb +8 -8
  150. data/lib/ffaker/name_vn.rb +4 -4
  151. data/lib/ffaker/nato_alphabet.rb +10 -10
  152. data/lib/ffaker/phone_number.rb +31 -21
  153. data/lib/ffaker/phone_number_au.rb +3 -3
  154. data/lib/ffaker/phone_number_br.rb +9 -8
  155. data/lib/ffaker/phone_number_ch.rb +7 -7
  156. data/lib/ffaker/phone_number_cu.rb +5 -5
  157. data/lib/ffaker/phone_number_de.rb +1 -1
  158. data/lib/ffaker/phone_number_fr.rb +4 -4
  159. data/lib/ffaker/phone_number_it.rb +2 -2
  160. data/lib/ffaker/phone_number_kr.rb +4 -4
  161. data/lib/ffaker/phone_number_mx.rb +4 -5
  162. data/lib/ffaker/phone_number_nl.rb +13 -13
  163. data/lib/ffaker/phone_number_se.rb +18 -19
  164. data/lib/ffaker/phone_number_sg.rb +8 -8
  165. data/lib/ffaker/phone_number_sn.rb +2 -2
  166. data/lib/ffaker/product.rb +18 -14
  167. data/lib/ffaker/skill.rb +3 -3
  168. data/lib/ffaker/sport.rb +1 -1
  169. data/lib/ffaker/ssn_se.rb +19 -20
  170. data/lib/ffaker/string.rb +21 -23
  171. data/lib/ffaker/time.rb +19 -7
  172. data/lib/ffaker/tweet.rb +59 -0
  173. data/lib/ffaker/unit.rb +12 -12
  174. data/lib/ffaker/unit_english.rb +34 -35
  175. data/lib/ffaker/unit_metric.rb +25 -25
  176. data/lib/ffaker/utils/array_utils.rb +12 -9
  177. data/lib/ffaker/utils/module_utils.rb +9 -6
  178. data/lib/ffaker/utils/random_utils.rb +33 -0
  179. data/lib/ffaker/vehicle.rb +21 -21
  180. data/lib/ffaker/venue.rb +1 -1
  181. data/lib/ffaker/youtube.rb +24 -0
  182. data/scripts/benchmark.rb +3 -3
  183. data/scripts/reference.rb +26 -23
  184. data/test/helper.rb +50 -0
  185. data/test/test_address.rb +40 -21
  186. data/test/test_address_au.rb +19 -9
  187. data/test/test_address_br.rb +9 -2
  188. data/test/test_address_ca.rb +7 -0
  189. data/test/test_address_ch.rb +6 -2
  190. data/test/test_address_ch_de.rb +7 -3
  191. data/test/test_address_ch_fr.rb +7 -3
  192. data/test/test_address_ch_it.rb +5 -1
  193. data/test/test_address_da.rb +18 -9
  194. data/test/test_address_de.rb +12 -5
  195. data/test/test_address_fi.rb +10 -3
  196. data/test/test_address_fr.rb +13 -0
  197. data/test/test_address_gr.rb +43 -0
  198. data/test/test_address_in.rb +20 -12
  199. data/test/test_address_kr.rb +14 -0
  200. data/test/test_address_mx.rb +12 -5
  201. data/test/test_address_nl.rb +11 -5
  202. data/test/test_address_ru.rb +11 -5
  203. data/test/test_address_se.rb +9 -3
  204. data/test/test_address_sn.rb +7 -1
  205. data/test/test_address_ua.rb +17 -10
  206. data/test/test_address_uk.rb +11 -3
  207. data/test/test_address_us.rb +15 -6
  208. data/test/test_airline.rb +17 -0
  209. data/test/test_array_utils.rb +51 -3
  210. data/test/test_avatar.rb +5 -1
  211. data/test/test_aws.rb +25 -0
  212. data/test/test_bacon_ipsum.rb +12 -6
  213. data/test/test_book.rb +41 -0
  214. data/test/test_boolean.rb +4 -0
  215. data/test/test_cheesy_lingo.rb +14 -10
  216. data/test/test_color.rb +126 -1
  217. data/test/test_color_ua.rb +5 -1
  218. data/test/test_company.rb +7 -0
  219. data/test/test_company_cn.rb +24 -0
  220. data/test/test_company_it.rb +7 -1
  221. data/test/test_company_se.rb +6 -0
  222. data/test/test_conference.rb +5 -2
  223. data/test/test_course_mathematiques.rb +5 -1
  224. data/test/test_course_philosophie.rb +5 -1
  225. data/test/test_currency.rb +12 -0
  226. data/test/test_dizzle_ipsum.rb +12 -6
  227. data/test/test_education.rb +9 -2
  228. data/test/test_faker.rb +8 -1
  229. data/test/test_food.rb +11 -4
  230. data/test/test_gender.rb +5 -1
  231. data/test/test_gender_br.rb +18 -0
  232. data/test/test_gender_cn.rb +5 -2
  233. data/test/test_gender_kr.rb +7 -3
  234. data/test/test_geolocation.rb +11 -8
  235. data/test/test_guid.rb +6 -1
  236. data/test/test_healthcare_ipsum.rb +13 -6
  237. data/test/test_hipster_ipsum.rb +13 -6
  238. data/test/test_html_ipsum.rb +28 -20
  239. data/test/test_identification.rb +9 -2
  240. data/test/test_identification_br.rb +46 -0
  241. data/test/test_identification_co.rb +7 -0
  242. data/test/test_identification_es.rb +5 -1
  243. data/test/test_identification_es_cl.rb +5 -1
  244. data/test/test_identification_es_mx.rb +7 -2
  245. data/test/test_identification_kr.rb +4 -0
  246. data/test/test_internet.rb +36 -5
  247. data/test/test_internet_se.rb +12 -4
  248. data/test/test_job.rb +4 -0
  249. data/test/test_job_br.rb +17 -0
  250. data/test/test_job_cn.rb +4 -0
  251. data/test/test_job_fr.rb +4 -0
  252. data/test/test_job_ja.rb +4 -0
  253. data/test/test_job_kr.rb +4 -0
  254. data/test/test_job_vn.rb +22 -0
  255. data/test/test_locale.rb +10 -4
  256. data/test/test_lorem.rb +18 -11
  257. data/test/test_lorem_ar.rb +16 -8
  258. data/test/test_lorem_cn.rb +9 -2
  259. data/test/test_lorem_fr.rb +16 -8
  260. data/test/test_lorem_ja.rb +81 -0
  261. data/test/test_lorem_kr.rb +17 -8
  262. data/test/test_lorem_ua.rb +15 -8
  263. data/test/test_module_utils.rb +2 -2
  264. data/test/test_movie.rb +5 -1
  265. data/test/test_music.rb +11 -4
  266. data/test/test_name.rb +114 -1
  267. data/test/test_name_br.rb +41 -2
  268. data/test/test_name_cn.rb +7 -0
  269. data/test/test_name_cs.rb +7 -0
  270. data/test/test_name_da.rb +13 -6
  271. data/test/test_name_de.rb +4 -0
  272. data/test/test_name_fr.rb +7 -0
  273. data/test/test_name_ga.rb +7 -0
  274. data/test/test_name_gr.rb +70 -0
  275. data/test/test_name_it.rb +7 -0
  276. data/test/test_name_ja.rb +7 -0
  277. data/test/test_name_kh.rb +32 -0
  278. data/test/test_name_kr.rb +7 -0
  279. data/test/test_name_mx.rb +9 -0
  280. data/test/test_name_nb.rb +8 -0
  281. data/test/test_name_nl.rb +4 -0
  282. data/test/test_name_ph.rb +7 -0
  283. data/test/test_name_ru.rb +10 -3
  284. data/test/test_name_se.rb +12 -4
  285. data/test/test_name_sn.rb +8 -0
  286. data/test/test_name_th.rb +7 -0
  287. data/test/test_name_th_en.rb +35 -0
  288. data/test/test_name_ua.rb +26 -17
  289. data/test/test_name_vn.rb +42 -0
  290. data/test/test_nato_alphabet.rb +15 -4
  291. data/test/test_phone_number.rb +24 -6
  292. data/test/test_phone_number_au.rb +17 -6
  293. data/test/test_phone_number_br.rb +22 -13
  294. data/test/test_phone_number_cu.rb +29 -18
  295. data/test/test_phone_number_da.rb +16 -7
  296. data/test/test_phone_number_de.rb +17 -9
  297. data/test/test_phone_number_kr.rb +9 -0
  298. data/test/test_phone_number_mx.rb +16 -8
  299. data/test/test_phone_number_nl.rb +9 -2
  300. data/test/test_phone_number_se.rb +12 -7
  301. data/test/test_phone_number_sg.rb +17 -9
  302. data/test/test_phone_number_sn.rb +12 -4
  303. data/test/test_products.rb +22 -0
  304. data/test/test_skill.rb +8 -2
  305. data/test/test_sports.rb +4 -0
  306. data/test/test_ssn.rb +3 -1
  307. data/test/test_ssn_mx.rb +6 -1
  308. data/test/test_ssn_se.rb +3 -0
  309. data/test/test_string.rb +28 -1
  310. data/test/test_time.rb +33 -2
  311. data/test/test_tweet.rb +59 -0
  312. data/test/test_units.rb +7 -0
  313. data/test/test_units_english.rb +9 -0
  314. data/test/test_units_metric.rb +9 -0
  315. data/test/test_vehicle.rb +24 -15
  316. data/test/test_venue.rb +5 -1
  317. data/test/test_youtube.rb +28 -0
  318. metadata +101 -5
  319. data/lib/ffaker/data/name/first_names +0 -3008
  320. data/lib/ffaker/data/name_br/first_names +0 -91
@@ -3,42 +3,50 @@
3
3
  require 'helper'
4
4
 
5
5
  class TestPhoneNumberSG < Test::Unit::TestCase
6
+ include DeterministicHelper
7
+
8
+ assert_methods_are_deterministic(
9
+ FFaker::PhoneNumberSG,
10
+ :voip_number, :fixed_line_number, :mobile_number, :mobile_or_pager_number,
11
+ :international_toll_free_number, :toll_free_number, :premium_service_number,
12
+ :phone_number
13
+ )
14
+
6
15
  def setup
7
16
  @tester = FFaker::PhoneNumberSG
8
17
  end
9
18
 
10
19
  def test_voip_number
11
- assert_match /3\d{3}\s\d{4}/, @tester.voip_number
20
+ assert_match(/3\d{3}\s\d{4}/, @tester.voip_number)
12
21
  end
13
22
 
14
23
  def test_fixed_line_number
15
- assert_match /6\d{3}\s\d{4}/, @tester.fixed_line_number
24
+ assert_match(/6\d{3}\s\d{4}/, @tester.fixed_line_number)
16
25
  end
17
26
 
18
27
  def test_mobile_number
19
- assert_match /8\d{3}\s\d{4}/, @tester.mobile_number
28
+ assert_match(/8\d{3}\s\d{4}/, @tester.mobile_number)
20
29
  end
21
30
 
22
31
  def test_mobile_or_pager_number
23
- assert_match /9\d{3}\s\d{4}/, @tester.mobile_or_pager_number
32
+ assert_match(/9\d{3}\s\d{4}/, @tester.mobile_or_pager_number)
24
33
  end
25
34
 
26
35
  def test_international_toll_free_number
27
- assert_match /800\s\d{3}\s\d{4}/, @tester.international_toll_free_number
36
+ assert_match(/800\s\d{3}\s\d{4}/, @tester.international_toll_free_number)
28
37
  end
29
38
 
30
39
  def test_toll_free_number
31
- assert_match /1800\s\d{3}\s\d{4}/, @tester.toll_free_number
40
+ assert_match(/1800\s\d{3}\s\d{4}/, @tester.toll_free_number)
32
41
  end
33
42
 
34
43
  def test_premium_service_number
35
- assert_match /1900\s\d{3}\s\d{4}/, @tester.premium_service_number
44
+ assert_match(/1900\s\d{3}\s\d{4}/, @tester.premium_service_number)
36
45
  end
37
46
 
38
47
  def test_phone_number
39
48
  10.times do
40
- assert_match /[6,8,9]\d{3}\s\d{4}/, @tester.phone_number
49
+ assert_match(/[6,8,9]\d{3}\s\d{4}/, @tester.phone_number)
41
50
  end
42
51
  end
43
52
  end
44
-
@@ -4,6 +4,14 @@ require 'helper'
4
4
 
5
5
  # Author: xarala<pathe.sene@xarala.sn> http://www.xarala.sn
6
6
  class TestPhoneNumberSN < Test::Unit::TestCase
7
+ include DeterministicHelper
8
+
9
+ assert_methods_are_deterministic(
10
+ FFaker::PhoneNumberSN,
11
+ :mobile_phone_prefix, :homework_phone_prefix, :mobile_number, :phone_number,
12
+ :homework_number, :short_phone_number
13
+ )
14
+
7
15
  def setup
8
16
  @tester = FFaker::PhoneNumberSN
9
17
  end
@@ -17,18 +25,18 @@ class TestPhoneNumberSN < Test::Unit::TestCase
17
25
  end
18
26
 
19
27
  def test_short_phone_number
20
- assert_match /\d{3}-\d{2}-\d{2}/, FFaker::PhoneNumberSN.short_phone_number
28
+ assert_match(/\d{3}-\d{2}-\d{2}/, FFaker::PhoneNumberSN.short_phone_number)
21
29
  end
22
30
 
23
31
  def test_mobile_phone_number
24
- assert_match /(70|76|77)-\d{3}-\d{2}-\d{2}/, FFaker::PhoneNumberSN.mobile_number
32
+ assert_match(/(70|76|77)-\d{3}-\d{2}-\d{2}/, FFaker::PhoneNumberSN.mobile_number)
25
33
  end
26
34
 
27
35
  def test_phone_number
28
- assert_match /(33|70|76|77)-\d{3}-\d{2}-\d{2}/, FFaker::PhoneNumberSN.phone_number
36
+ assert_match(/(33|70|76|77)-\d{3}-\d{2}-\d{2}/, FFaker::PhoneNumberSN.phone_number)
29
37
  end
30
38
 
31
39
  def test_homework_phone_number
32
- assert_match /(33)-(8|9)\d{2}-\d{2}-\d{2}/, FFaker::PhoneNumberSN.homework_number
40
+ assert_match(/(33)-(8|9)\d{2}-\d{2}-\d{2}/, FFaker::PhoneNumberSN.homework_number)
33
41
  end
34
42
  end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ class TestProducts < Test::Unit::TestCase
6
+ include DeterministicHelper
7
+
8
+ assert_methods_are_deterministic(
9
+ FFaker::Product,
10
+ :brand, :product_name, :product, :model
11
+ )
12
+
13
+ def test_letters_max_as_int
14
+ assert_match(/\A[A-Z]{10}\z/, FFaker::Product.letters(10))
15
+ assert_deterministic { FFaker::Product.letters(10) }
16
+ end
17
+
18
+ def test_letters_max_as_range
19
+ assert_match(/\A[A-Z]{5,10}\z/, FFaker::Product.letters(5..10))
20
+ assert_deterministic { FFaker::Product.letters(5..10) }
21
+ end
22
+ end
@@ -3,9 +3,15 @@
3
3
  require 'helper'
4
4
 
5
5
  class TestSkill < Test::Unit::TestCase
6
+ include DeterministicHelper
7
+
8
+ assert_methods_are_deterministic(
9
+ FFaker::Skill,
10
+ :tech_skill, :tech_skills, :specialty, :specialties
11
+ )
6
12
 
7
13
  def test_tech_skill
8
- assert_match /[a-z]+/i, FFaker::Skill.tech_skill
14
+ assert_match(/[a-z]+/i, FFaker::Skill.tech_skill)
9
15
  end
10
16
 
11
17
  def test_tech_skills
@@ -14,7 +20,7 @@ class TestSkill < Test::Unit::TestCase
14
20
  end
15
21
 
16
22
  def test_specialty
17
- assert_match /[ a-z]+/i, FFaker::Skill.specialty
23
+ assert_match(/[ a-z]+/i, FFaker::Skill.specialty)
18
24
  end
19
25
 
20
26
  def test_specialties
@@ -3,6 +3,10 @@
3
3
  require 'helper'
4
4
 
5
5
  class TestSports < Test::Unit::TestCase
6
+ include DeterministicHelper
7
+
8
+ assert_methods_are_deterministic(FFaker::Sport, :name)
9
+
6
10
  def setup
7
11
  @tester = FFaker::Sport
8
12
  end
@@ -3,9 +3,11 @@
3
3
  require 'helper'
4
4
 
5
5
  class TestSSN < Test::Unit::TestCase
6
+ include DeterministicHelper
7
+
8
+ assert_methods_are_deterministic(FFaker::SSN, :ssn)
6
9
 
7
10
  def test_ssn
8
11
  assert_match(/\d{3}-\d{2}-\d{3}/, FFaker::SSN.ssn)
9
12
  end
10
-
11
13
  end
@@ -4,6 +4,12 @@ require 'helper'
4
4
 
5
5
  # Author Guapolo <github.com/guapolo>
6
6
  class TestSSNMX < Test::Unit::TestCase
7
+ include DeterministicHelper
8
+
9
+ assert_methods_are_deterministic(
10
+ FFaker::SSNMX,
11
+ :ssn, :ssn_undashed, :imss, :imss_undashed, :issste, :issste_undashed
12
+ )
7
13
 
8
14
  def test_ssn
9
15
  assert_match(/\d{10}-\d/, FFaker::SSNMX.ssn)
@@ -28,5 +34,4 @@ class TestSSNMX < Test::Unit::TestCase
28
34
  def test_issste_undashed
29
35
  assert_match(/\d{11}/, FFaker::SSNMX.issste_undashed)
30
36
  end
31
-
32
37
  end
@@ -3,6 +3,9 @@
3
3
  require 'helper'
4
4
 
5
5
  class TestSSNSE < Test::Unit::TestCase
6
+ include DeterministicHelper
7
+
8
+ assert_methods_are_deterministic(FFaker::SSNSE, :ssn)
6
9
 
7
10
  def test_ssn_format
8
11
  ssn = FFaker::SSNSE.ssn
@@ -3,85 +3,112 @@
3
3
  require 'helper'
4
4
 
5
5
  class TestString < Test::Unit::TestCase
6
+ include DeterministicHelper
7
+
6
8
  FS = FFaker::String
7
9
 
8
10
  def test_atoms
9
11
  assert_equal 'abc', FS.from_regexp(/abc/)
12
+ assert_deterministic { FS.from_regexp(/abc/) }
10
13
  end
11
14
 
12
15
  def test_digits
13
16
  assert_match(/\A\d\d\d\z/, FS.from_regexp(/\d\d\d/))
17
+ assert_deterministic { FS.from_regexp(/\d\d\d/) }
14
18
  end
15
19
 
16
20
  def test_word_characters
17
21
  assert_match(/\A\w\w\w\z/, FS.from_regexp(/\w\w\w/))
22
+ assert_deterministic { FS.from_regexp(/\w\w\w/) }
18
23
  end
19
24
 
20
25
  def test_word_range_character
21
26
  assert_match(/\A[a-z]\z/, FS.from_regexp(/[a-z]/))
27
+ assert_deterministic { FS.from_regexp(/[a-z]/) }
22
28
  end
23
29
 
24
30
  def test_dash_character
25
31
  assert_match(/\A[a-z-]\z/, FS.from_regexp(/[a-z-]/))
26
32
  assert_match(/\A[a-]\z/, FS.from_regexp(/[a-]/))
27
33
  assert_match(/\A[-]\z/, FS.from_regexp(/[-]/))
34
+
35
+ assert_deterministic { FS.from_regexp(/[a-z-]/) }
36
+ assert_deterministic { FS.from_regexp(/[a-]/) }
37
+ assert_deterministic { FS.from_regexp(/[-]/) }
28
38
  end
29
39
 
30
40
  def test_spaces
31
41
  assert_match(/\A\s\s\s\z/, FS.from_regexp(/\s\s\s/))
42
+ assert_deterministic { FS.from_regexp(/\s\s\s/) }
32
43
  end
33
44
 
34
45
  def test_escaped_characters
35
46
  assert_equal '\\/.()[]{}', FS.from_regexp(/\\\/\.\(\)\[\]\{\}/)
47
+ assert_deterministic { FS.from_regexp(%r|\\\/\.\(\)\[\]\{\}|) }
36
48
  end
37
49
 
38
50
  def test_atom_sets
39
51
  assert_include %w(a b c), FS.from_regexp(/[abc]/)
52
+ assert_deterministic { FS.from_regexp(/[abc]/) }
40
53
  end
41
54
 
42
55
  def test_special_sets
43
56
  assert_match(/\A[\w\d]\z/, FS.from_regexp(/[\w\d]/))
57
+ assert_deterministic { FS.from_regexp(/[\w\d]/) }
44
58
  end
45
59
 
46
60
  def test_atom_question
47
61
  assert_match(/\Aa?\z/, FS.from_regexp(/a?/))
62
+ assert_deterministic { FS.from_regexp(/a?/) }
48
63
  end
49
64
 
50
65
  def test_special_question
51
66
  assert_match(/\A\w?\z/, FS.from_regexp(/\w?/))
67
+ assert_deterministic { FS.from_regexp(/\w?/) }
52
68
  end
53
69
 
54
70
  def test_set_question
55
71
  assert_match(/\A[abc]?\z/, FS.from_regexp(/[abc]?/))
72
+ assert_deterministic { FS.from_regexp(/[abc]?/) }
56
73
  end
57
74
 
58
75
  def test_atom_plus
59
76
  assert_match(/\Aa+\z/, FS.from_regexp(/a+/))
77
+ assert_deterministic { FS.from_regexp(/a+/) }
60
78
  end
61
79
 
62
80
  def test_special_plus
63
81
  assert_match(/\A\w+\z/, FS.from_regexp(/\w+/))
82
+ assert_deterministic { FS.from_regexp(/\w+/) }
64
83
  end
65
84
 
66
85
  def test_set_plus
67
86
  assert_match(/\A[abc]+\z/, FS.from_regexp(/[abc]+/))
87
+ assert_deterministic { FS.from_regexp(/[abc]+/) }
68
88
  end
69
89
 
70
90
  def test_atom_star
71
91
  assert_match(/\Aa*\z/, FS.from_regexp(/a*/))
92
+ assert_deterministic { FS.from_regexp(/a*/) }
72
93
  end
73
94
 
74
95
  def test_special_star
75
96
  assert_match(/\A\w*\z/, FS.from_regexp(/\w*/))
97
+ assert_deterministic { FS.from_regexp(/\w*/) }
76
98
  end
77
99
 
78
100
  def test_set_star
79
101
  assert_match(/\A[abc]*\z/, FS.from_regexp(/[abc]*/))
102
+ assert_deterministic { FS.from_regexp(/[abc]*/) }
80
103
  end
81
104
 
82
105
  def test_braces
83
- assert_equal "a" * 13, FS.from_regexp(/a{13}/)
106
+ assert_equal 'a' * 13, FS.from_regexp(/a{13}/)
84
107
  assert_match(/\A[abc]{13}\z/, FS.from_regexp(/[abc]{13}/))
85
108
  assert_match(/\A\w{13}\z/, FS.from_regexp(/\w{13}/))
109
+
110
+ assert_deterministic { FS.from_regexp(/a{13}/) }
111
+ assert_deterministic { FS.from_regexp(/[abc]{13}/) }
112
+ assert_deterministic { FS.from_regexp(/\w{13}/) }
86
113
  end
87
114
  end
@@ -3,17 +3,48 @@
3
3
  require 'helper'
4
4
 
5
5
  class TestFakerTime < Test::Unit::TestCase
6
+ include DeterministicHelper
7
+
8
+ assert_methods_are_deterministic(FFaker::Time, :date, :datetime, :month)
9
+
6
10
  def setup
7
11
  @tester = FFaker::Time
8
12
  end
9
13
 
10
14
  def test_date
11
15
  date_regex = /\A\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [-|+]\d{4}\z/
12
- assert_match date_regex, @tester.date.to_s
16
+ assert_match(date_regex, @tester.date)
17
+ end
18
+
19
+ def test_date_hours_and_minutes
20
+ assert_match('04:20:00', @tester.date(hours: 4, minutes: 20))
21
+ assert_deterministic { @tester.date(hours: 4, minutes: 20) }
22
+ end
23
+
24
+ def test_datetime
25
+ date_regex = /\A\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [-|+]\d{4}\z/
26
+ assert_match(date_regex, @tester.datetime)
27
+ end
28
+
29
+ def test_datetime_hours_and_minutes
30
+ assert_match('04:20:00', @tester.datetime(hours: 4, minutes: 20))
31
+ assert_deterministic { @tester.datetime(hours: 4, minutes: 20) }
13
32
  end
14
33
 
15
34
  def test_month
16
35
  month_regex = /\A(?:January|February|March|April|May|June|July|August|September|October|November|December)\z/
17
- assert_match month_regex, @tester.month
36
+ assert_match(month_regex, @tester.month)
37
+ end
38
+
39
+ def test_between
40
+ from = Time.local(2015, 1, 1)
41
+ to = Time.local(2016, 1, 1)
42
+
43
+ 100.times do
44
+ random_date = @tester.between(from, to)
45
+ assert random_date >= from, "Expected >= \"#{from}\", but got #{random_date}"
46
+ assert random_date <= to, "Expected <= \"#{to}\", but got #{random_date}"
47
+ assert_deterministic { @tester.between(from, to) }
48
+ end
18
49
  end
19
50
  end
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ class TestTweet < Test::Unit::TestCase
6
+ include DeterministicHelper
7
+
8
+ assert_methods_are_deterministic(
9
+ FFaker::Tweet,
10
+ :tags, :mention, :body, :tweet
11
+ )
12
+
13
+ def test_2_tags
14
+ assert_match(/\#\S*\s\#\S*/, FFaker::Tweet.tags)
15
+ end
16
+
17
+ def test_3_tags
18
+ assert_match(/\#\S*\s\#\S*\s\#\S*/, FFaker::Tweet.tags(3))
19
+ assert_deterministic { FFaker::Tweet.tags(3) }
20
+ end
21
+
22
+ def test_mention
23
+ assert_match(/\@\S*/, FFaker::Tweet.mention)
24
+ end
25
+
26
+ def test_mentions_three
27
+ assert_match(/\@\S*\s\@\S*\s\@\S*/, FFaker::Tweet.mentions(3))
28
+ assert_deterministic { FFaker::Tweet.mentions(3) }
29
+ end
30
+
31
+ def test_body
32
+ assert(FFaker::Tweet.body.size <= 140)
33
+ end
34
+
35
+ def test_shortish_body
36
+ assert(FFaker::Tweet.body(20).size <= 20)
37
+ end
38
+
39
+ def test_short_body
40
+ assert(FFaker::Tweet.body(2).size.between?(2, 20))
41
+ end
42
+
43
+ def test_tweet
44
+ 100.times { assert(FFaker::Tweet.tweet.size <= 140) }
45
+ end
46
+
47
+ def test_tweet_with_reply
48
+ assert_match(/^\@/, FFaker::Tweet.tweet(reply: true))
49
+ assert_deterministic { FFaker::Tweet.tweet(reply: true) }
50
+ end
51
+
52
+ def test_oversize_body_length
53
+ assert(FFaker::Tweet.tweet(body_length: 200).size <= 140)
54
+ end
55
+
56
+ def test_undersize_body_length
57
+ assert(FFaker::Tweet.tweet(body_length: 2).size <= 140)
58
+ end
59
+ end
@@ -4,6 +4,13 @@ require 'helper'
4
4
 
5
5
  # Author: lurraca github.com/lurraca
6
6
  class TestUnits < Test::Unit::TestCase
7
+ include DeterministicHelper
8
+
9
+ assert_methods_are_deterministic(
10
+ FFaker::Unit,
11
+ :time_name, :time_abbr, :temperature_name, :temperature_abbr
12
+ )
13
+
7
14
  def setup
8
15
  @tester = FFaker::Unit
9
16
  @time_units = @tester::TIME_UNITS.map { |u| OpenStruct.new u }
@@ -4,6 +4,15 @@ require 'helper'
4
4
 
5
5
  # Author: lurraca github.com/lurraca
6
6
  class TestUnitsEnglish < Test::Unit::TestCase
7
+ include DeterministicHelper
8
+
9
+ assert_methods_are_deterministic(
10
+ FFaker::UnitEnglish,
11
+ :length_name, :length_abbr, :mass_name, :mass_abbr,
12
+ :liquid_name, :liquid_abbr, :volume_name, :volume_abbr,
13
+ :area_name, :area_abbr
14
+ )
15
+
7
16
  def setup
8
17
  @tester = FFaker::UnitEnglish
9
18
  @length_units = @tester::LENGTH_UNITS.map { |u| OpenStruct.new u }