ffaker 1.24.0 → 1.25.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 +7 -15
  2. data/Changelog.md +4 -0
  3. data/ffaker.gemspec +42 -2
  4. data/lib/ffaker.rb +1 -1
  5. data/lib/ffaker/address_fi.rb +48 -0
  6. data/lib/ffaker/address_mx.rb +3 -9
  7. data/lib/ffaker/address_nl.rb +43 -0
  8. data/lib/ffaker/boolean.rb +16 -0
  9. data/lib/ffaker/color.rb +13 -0
  10. data/lib/ffaker/data/address_fi/city +107 -0
  11. data/lib/ffaker/data/address_fi/countries +96 -0
  12. data/lib/ffaker/data/address_fi/street +140 -0
  13. data/lib/ffaker/data/address_nl/city +2226 -0
  14. data/lib/ffaker/data/address_nl/province +12 -0
  15. data/lib/ffaker/data/color/names_list +19 -0
  16. data/lib/ffaker/data/food/fruit +82 -0
  17. data/lib/ffaker/data/food/herb_spice +64 -0
  18. data/lib/ffaker/data/food/meat +48 -0
  19. data/lib/ffaker/data/food/vegetable +207 -0
  20. data/lib/ffaker/data/identification_mx/estados_curp +33 -0
  21. data/lib/ffaker/data/job_ja/job_nouns +235 -0
  22. data/lib/ffaker/data/name_nl/first_names_female +89 -0
  23. data/lib/ffaker/data/name_nl/first_names_male +75 -0
  24. data/lib/ffaker/data/name_nl/last_names +115 -0
  25. data/lib/ffaker/data/vehicle/makes_list +74 -0
  26. data/lib/ffaker/data/vehicle/models_list +106 -0
  27. data/lib/ffaker/data/vehicle/trims_list +13 -0
  28. data/lib/ffaker/food.rb +27 -0
  29. data/lib/ffaker/identification_mx.rb +49 -0
  30. data/lib/ffaker/internet.rb +15 -0
  31. data/lib/ffaker/internet_se.rb +7 -0
  32. data/lib/ffaker/job_ja.rb +12 -0
  33. data/lib/ffaker/lorem.rb +1 -1
  34. data/lib/ffaker/name_nl.rb +50 -0
  35. data/lib/ffaker/name_ru.rb +1 -1
  36. data/lib/ffaker/phone_number_nl.rb +52 -0
  37. data/lib/ffaker/ssn_mx.rb +57 -0
  38. data/lib/ffaker/vehicle.rb +50 -0
  39. data/test/test_address_fi.rb +33 -0
  40. data/test/test_address_mx.rb +9 -9
  41. data/test/test_address_nl.rb +30 -0
  42. data/test/test_boolean.rb +10 -0
  43. data/test/test_color.rb +9 -0
  44. data/test/test_food.rb +21 -0
  45. data/test/test_identification_es_mx.rb +24 -0
  46. data/test/test_internet.rb +7 -0
  47. data/test/test_internet_se.rb +4 -1
  48. data/test/test_job_ja.rb +17 -0
  49. data/test/test_lorem.rb +3 -0
  50. data/test/test_name_br.rb +4 -2
  51. data/test/test_name_nl.rb +21 -0
  52. data/test/test_phone_number_nl.rb +30 -0
  53. data/test/test_ssn_mx.rb +32 -0
  54. data/test/test_vehicle.rb +41 -0
  55. metadata +90 -45
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+
3
+ module Faker
4
+ # Author Guapolo <github.com/guapolo>
5
+ module SSNMX
6
+ extend ModuleUtils
7
+ extend self
8
+
9
+ # The Social Security number is a eleven-digit number in the format
10
+ # "AABBCCDDEE-F".
11
+ def ssn
12
+ Faker.numerify('##########-#')
13
+ end
14
+
15
+ # The Social Security number is a eleven-digit number in the format
16
+ # "AABBCCDDEEF".
17
+ def ssn_undashed
18
+ Faker.numerify('###########')
19
+ end
20
+
21
+ # http://es.wikipedia.org/wiki/Instituto_Mexicano_del_Seguro_Social
22
+ # The Social Security number from IMSS
23
+ # (Instituto Mexicano del Seguro Social)
24
+ # is a eleven-digit number in the format
25
+ # "AABBCCDDEE-F".
26
+ def imss
27
+ Faker.numerify('##########-#')
28
+ end
29
+
30
+ # http://es.wikipedia.org/wiki/Instituto_Mexicano_del_Seguro_Social
31
+ # The Social Security number from IMSS
32
+ # (Instituto Mexicano del Seguro Social)
33
+ # is a eleven-digit number in the format
34
+ # "AABBCCDDEEF".
35
+ def imss_undashed
36
+ Faker.numerify('###########')
37
+ end
38
+
39
+ # http://es.wikipedia.org/wiki/Instituto_de_Seguridad_y_Servicios_Sociales_de_los_Trabajadores_del_Estado
40
+ # The Social Security number from ISSSTE
41
+ # (Instituto de Seguridad y Servicios Sociales de los Trabajadores del Estado)
42
+ # is a eleven-digit number in the format
43
+ # "AABBCCDDEE-F".
44
+ def issste
45
+ Faker.numerify('##########-#')
46
+ end
47
+
48
+ # http://es.wikipedia.org/wiki/Instituto_de_Seguridad_y_Servicios_Sociales_de_los_Trabajadores_del_Estado
49
+ # The Social Security number from ISSSTE
50
+ # (Instituto de Seguridad y Servicios Sociales de los Trabajadores del Estado)
51
+ # is a eleven-digit number in the format
52
+ # "AABBCCDDEEF".
53
+ def issste_undashed
54
+ Faker.numerify('###########')
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ module Faker
4
+ module Vehicle
5
+ extend ModuleUtils
6
+ extend self
7
+
8
+ def base_color
9
+ Faker::Color.name
10
+ end
11
+
12
+ def drivetrain
13
+ DRIVETRAINS.rand
14
+ end
15
+
16
+ def make
17
+ MAKES_LIST.rand
18
+ end
19
+
20
+ def manufacturer_color(n=2)
21
+ # Take two prefixes because it's more fun than one
22
+ [COLOR_PREFIXES.random_pick(n), self.base_color].flatten.join(' ')
23
+ end
24
+ alias_method :mfg_color, :manufacturer_color
25
+
26
+ def model
27
+ MODELS_LIST.rand
28
+ end
29
+
30
+ def trim
31
+ TRIMS_LIST.rand
32
+ end
33
+
34
+ def vin
35
+ Faker.bothify('1#???#####?######').upcase
36
+ end
37
+
38
+ def year
39
+ YEARS.rand
40
+ end
41
+
42
+ DRIVETRAINS = k(%w(4WD 4X4 AWD FWD RWD))
43
+ YEARS = k('1900'.."#{Date.today.year+1}")
44
+ COLOR_PREFIXES = k(%w(
45
+ beautiful bright calm dangerous dark dull fast magnetic magnificent majestic melodic metallic
46
+ mundane mute mysterious new pleasant pretty resonant royal slate soft tranquil vibrant weak
47
+ ))
48
+
49
+ end
50
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ # Test features related to Finnish addresses
6
+ class TestAddressFI < Test::Unit::TestCase
7
+ ALPHA = /\A[[:alpha:]]+/
8
+ DIGIT = /\d{1}/
9
+
10
+ def test_fi_city
11
+ assert_match ALPHA, Faker::AddressFI.city
12
+ end
13
+
14
+ def test_fi_zip_code
15
+ assert_match(/\d{2}/, Faker::AddressFI.zip_code)
16
+ end
17
+
18
+ def test_countries
19
+ assert Faker::AddressFI::COUNTRIES.include?(Faker::AddressFI.random_country)
20
+ end
21
+
22
+ def test_fi_full_address
23
+ address = Faker::AddressFI.full_address
24
+ assert_match ALPHA, address
25
+ assert_match DIGIT, address
26
+ assert_match(/SUOMI/, address)
27
+ assert_match(/[\, a-z]/, address)
28
+ end
29
+
30
+ def test_fi_zip_code_frozen
31
+ assert Faker::AddressFI.zip_code.frozen? == false
32
+ end
33
+ end
@@ -4,23 +4,23 @@ require 'helper'
4
4
 
5
5
  # Author: guapolo github.com/guapolo
6
6
  class TestAddressMX < Test::Unit::TestCase
7
- def setup
8
- @tester = Faker::AddressMX
9
- end
10
-
11
7
  def test_mx_state
12
- assert_match /[ A-Za-z]/, @tester.state
8
+ assert_match /[\sa-z]/i, Faker::AddressMX.state
13
9
  end
14
10
 
15
11
  def test_mx_state_abbr
16
- assert_match /[A-Z]/, @tester.state_abbr
12
+ assert_match /[A-Z]/, Faker::AddressMX.state_abbr
13
+ end
14
+
15
+ def test_postal_code
16
+ assert_match /[0-9]/, Faker::AddressMX.postal_code
17
17
  end
18
18
 
19
- def test_postcode
20
- assert_match /[0-9]/, @tester.zip_code
19
+ def test_zip_code
20
+ assert_match /[0-9]/, Faker::AddressMX.zip_code
21
21
  end
22
22
 
23
23
  def test_mx_municipality
24
- assert_match /[ a-z]/, @tester.municipality
24
+ assert_match /[\sa-z]/i, Faker::AddressMX.municipality
25
25
  end
26
26
  end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ class TestAddressNL < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @tester = Faker::AddressNL
9
+ end
10
+
11
+ def test_city
12
+ assert_match /[ a-z]+/, @tester.city
13
+ end
14
+
15
+ def test_province
16
+ assert_match /[ a-z]/, @tester.province
17
+ end
18
+
19
+ def test_zip_code
20
+ assert_match /^\d{4}\s\w{2}$/, @tester.zip_code
21
+ end
22
+
23
+ def test_street_name
24
+ assert_match /[ a-z]+/, @tester.street_name
25
+ end
26
+
27
+ def test_street_address
28
+ assert_match /[ a-z]+/, @tester.street_address
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ class TestBoolean < Test::Unit::TestCase
6
+ def test_maybe
7
+ maybe = Faker::Boolean.maybe
8
+ assert (maybe == false || maybe == true)
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ class TestColor < Test::Unit::TestCase
6
+ def test_name
7
+ assert_match /\A[a-z]+\z/, Faker::Color.name
8
+ end
9
+ end
data/test/test_food.rb ADDED
@@ -0,0 +1,21 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'helper'
4
+
5
+ class TestFakerFood < Test::Unit::TestCase
6
+ def test_vegetable
7
+ assert_match /\A[-\/ 'a-z0-9]+\z/i, Faker::Food.vegetable
8
+ end
9
+
10
+ def test_fruit
11
+ assert_match /\A[ a-z0-9]+\z/i, Faker::Food.fruit
12
+ end
13
+
14
+ def test_meat
15
+ assert_match /\A[, a-z0-9]+\z/i, Faker::Food.meat
16
+ end
17
+
18
+ def test_herb_or_spice
19
+ assert_match /\A[-, a-z0-9]+\z/i, Faker::Food.herb_or_spice
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ # Author Guapolo <github.com/guapolo>
6
+ class TestIdentificationMX < Test::Unit::TestCase
7
+
8
+ def test_rfc_persona_moral
9
+ re = /\A[a-zñÑ&]{3}\d{2}[0-1][0-9][0-3][0-9][a-z0-9]{3}\z/i
10
+ assert_match(re, Faker::IdentificationMX.rfc_persona_moral)
11
+ end
12
+
13
+ def test_rfc_persona_fisica
14
+ re = /\A[a-zñÑ]{4}\d{2}[0-1][0-9][0-3][0-9][a-z0-9]{3}\z/i
15
+ assert_match(re, Faker::IdentificationMX.rfc_persona_fisica)
16
+ end
17
+
18
+ def test_curp
19
+ or_curp_states_abbr = Faker::IdentificationMX::ESTADOS_CURP.join("|")
20
+ re = /\A[a-z][aeioux][a-z]{2}[0-9]{2}[0-1][0-9][0-3][0-9][hm]#{or_curp_states_abbr}[bcdfghjklmnñpqrstvwxyz]{3}[0-9a-z][0-9]\z/i
21
+ assert_match(re, Faker::IdentificationMX.curp)
22
+ end
23
+
24
+ end
@@ -57,4 +57,11 @@ class TestFakerInternet < Test::Unit::TestCase
57
57
  assert @tester.ip_v4_address.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
58
58
  end
59
59
 
60
+ def test_slug
61
+ assert @tester.slug.match(/^[a-z]+(_|\.|\-)[a-z]+$/)
62
+ end
63
+
64
+ def test_password
65
+ assert @tester.password.match(/[a-z]+/)
66
+ end
60
67
  end
@@ -63,5 +63,8 @@ class TestFakerInternetSE < Test::Unit::TestCase
63
63
  assert @tester.ip_v4_address.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
64
64
  end
65
65
 
66
- end
66
+ def test_slug
67
+ assert @tester.slug.match(/^[a-z]+(_|\.|\-)[a-z]+$/)
68
+ end
67
69
 
70
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'helper'
4
+
5
+ class TestFakerJobJA < Test::Unit::TestCase
6
+ def setup
7
+ @tester = Faker::JobJA
8
+ end
9
+
10
+ def test_title
11
+ assert @tester.title.length >= 1
12
+ end
13
+
14
+ def test_nouns
15
+ assert @tester::JOB_NOUNS.is_a?(Array)
16
+ end
17
+ end
data/test/test_lorem.rb CHANGED
@@ -9,6 +9,9 @@ class TestLorem < Test::Unit::TestCase
9
9
 
10
10
  def test_sentence
11
11
  assert_match /[ a-z]+/, Faker::Lorem.sentence
12
+ assert_nothing_thrown do
13
+ 100.times { Faker::Lorem.sentence 0 }
14
+ end
12
15
  end
13
16
 
14
17
  def test_phrase
data/test/test_name_br.rb CHANGED
@@ -12,8 +12,10 @@ class TestFakerNameBR < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  def test_name_with_prefix
15
- prefixes = @tester::PREFIXES.map { |p| Regexp.escape(p) }
16
- assert_match /(#{prefixes.join('|')}) [[:alpha:]]+ [[:alpha:]]+/, @tester.name_with_prefix
15
+ prefixes = @tester::PREFIXES
16
+ parts = @tester.name_with_prefix.split(/\s+/)
17
+ assert prefixes.include?(parts.first)
18
+ assert(parts[1].length > 0)
17
19
  end
18
20
 
19
21
  def test_first_name
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ class TestFakerNameNL < Test::Unit::TestCase
6
+ def setup
7
+ @tester = Faker::NameNL
8
+ end
9
+
10
+ def test_name
11
+ assert @tester.name.match(/(\w+\.? ?){2,3}/)
12
+ end
13
+
14
+ def test_prefix
15
+ assert @tester.prefix.match(/[A-Z][a-z]+\.?/)
16
+ end
17
+
18
+ def test_suffix
19
+ assert @tester.suffix.match(/[A-Z][a-z]*\.?/)
20
+ end
21
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ # Author: wiseleyb<wiseleyb@gmail.com>
6
+ class TestPhoneNumberNL < Test::Unit::TestCase
7
+ def setup
8
+ @tester = Faker::PhoneNumberNL
9
+ end
10
+
11
+ def test_mobile_phone_prefix
12
+ assert @tester.mobile_phone_number.start_with?('06')
13
+ end
14
+
15
+ def test_phone_prefix
16
+ assert @tester.phone_number.start_with?('0')
17
+ end
18
+
19
+ def test_phone_number
20
+ 10.times do
21
+ assert_match /^0([\s\-]*\d){9}$/, @tester.phone_number
22
+ end
23
+ end
24
+
25
+ def test_international_phone_number
26
+ 10.times do
27
+ assert_match /^\+31/, @tester.international_phone_number
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ # Author Guapolo <github.com/guapolo>
6
+ class TestSSNMX < Test::Unit::TestCase
7
+
8
+ def test_ssn
9
+ assert_match(/\d{10}-\d/, Faker::SSNMX.ssn)
10
+ end
11
+
12
+ def test_ssn_undashed
13
+ assert_match(/\d{11}/, Faker::SSNMX.ssn_undashed)
14
+ end
15
+
16
+ def test_imss
17
+ assert_match(/\d{10}-\d/, Faker::SSNMX.imss)
18
+ end
19
+
20
+ def test_imss_undashed
21
+ assert_match(/\d{11}/, Faker::SSNMX.imss_undashed)
22
+ end
23
+
24
+ def test_issste
25
+ assert_match(/\d{10}-\d/, Faker::SSNMX.issste)
26
+ end
27
+
28
+ def test_issste_undashed
29
+ assert_match(/\d{11}/, Faker::SSNMX.issste_undashed)
30
+ end
31
+
32
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ class TestVehicle < Test::Unit::TestCase
6
+ def test_base_color
7
+ assert_match /\A[a-z]+\z/, Faker::Vehicle.base_color
8
+ end
9
+
10
+ def test_year
11
+ assert_match /\A\d{4}\z/, Faker::Vehicle.year
12
+ end
13
+
14
+ def test_manufacturer_color
15
+ assert_match /\A[ a-z]+\z/, Faker::Vehicle.manufacturer_color
16
+ end
17
+
18
+ def test_mfg_color
19
+ assert_match /\A[ a-z]+\z/, Faker::Vehicle.mfg_color
20
+ end
21
+
22
+ def test_make
23
+ assert_match /\A[A-Z][- A-Za-z]+\z/, Faker::Vehicle.make
24
+ end
25
+
26
+ def test_model
27
+ assert_match /\A[-\. a-z0-9]+\z/i, Faker::Vehicle.model
28
+ end
29
+
30
+ def test_trim
31
+ assert_match /\A[- a-z]+\z/i, Faker::Vehicle.trim
32
+ end
33
+
34
+ def test_vin
35
+ assert_match /\A[A-Z0-9]{17}\z/, Faker::Vehicle.vin
36
+ end
37
+
38
+ def test_drivetrain
39
+ assert_match /\A[a-z0-9]+\z/i, Faker::Vehicle.drivetrain
40
+ end
41
+ end