faker 1.6.3 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +13 -0
  3. data/README.md +185 -23
  4. data/lib/faker.rb +20 -0
  5. data/lib/faker/app.rb +1 -1
  6. data/lib/faker/beer.rb +1 -1
  7. data/lib/faker/chuck_norris.rb +16 -0
  8. data/lib/faker/code.rb +59 -0
  9. data/lib/faker/company.rb +19 -0
  10. data/lib/faker/crypto.rb +19 -0
  11. data/lib/faker/date.rb +30 -2
  12. data/lib/faker/educator.rb +23 -0
  13. data/lib/faker/file.rb +23 -0
  14. data/lib/faker/internet.rb +24 -15
  15. data/lib/faker/lorem.rb +21 -7
  16. data/lib/faker/music.rb +21 -0
  17. data/lib/faker/name.rb +7 -0
  18. data/lib/faker/placeholdit.rb +3 -3
  19. data/lib/faker/space.rb +54 -0
  20. data/lib/faker/time.rb +7 -18
  21. data/lib/faker/vehicle.rb +37 -0
  22. data/lib/faker/version.rb +1 -1
  23. data/lib/faker/yoda.rb +10 -0
  24. data/lib/locales/de.yml +26 -8
  25. data/lib/locales/en-GB.yml +1 -1
  26. data/lib/locales/en-PAK.yml +17 -0
  27. data/lib/locales/en.yml +195 -4
  28. data/lib/locales/es-MX.yml +82 -0
  29. data/lib/locales/es.yml +4 -0
  30. data/lib/locales/fr.yml +7 -4
  31. data/lib/locales/pt-BR.yml +51 -23
  32. metadata +13 -103
  33. data/test/test_array_sample_method_compat.rb +0 -56
  34. data/test/test_avatar.rb +0 -43
  35. data/test/test_ca_cat_locale.rb +0 -35
  36. data/test/test_ca_locale.rb +0 -22
  37. data/test/test_da_dk_locale.rb +0 -32
  38. data/test/test_en_au_locale.rb +0 -24
  39. data/test/test_en_au_ocker_locale.rb +0 -25
  40. data/test/test_en_ca_locale.rb +0 -18
  41. data/test/test_en_locale.rb +0 -35
  42. data/test/test_en_nz_locale.rb +0 -33
  43. data/test/test_en_ug_locale.rb +0 -23
  44. data/test/test_en_us_locale.rb +0 -89
  45. data/test/test_es_locale.rb +0 -34
  46. data/test/test_faker.rb +0 -29
  47. data/test/test_faker_app.rb +0 -12
  48. data/test/test_faker_beer.rb +0 -41
  49. data/test/test_faker_bitcoin.rb +0 -14
  50. data/test/test_faker_book.rb +0 -24
  51. data/test/test_faker_boolean.rb +0 -23
  52. data/test/test_faker_business.rb +0 -34
  53. data/test/test_faker_cat.rb +0 -20
  54. data/test/test_faker_city.rb +0 -52
  55. data/test/test_faker_code.rb +0 -35
  56. data/test/test_faker_color.rb +0 -50
  57. data/test/test_faker_commerce.rb +0 -84
  58. data/test/test_faker_company.rb +0 -34
  59. data/test/test_faker_date.rb +0 -89
  60. data/test/test_faker_hacker_talk.rb +0 -37
  61. data/test/test_faker_hipster.rb +0 -78
  62. data/test/test_faker_internet.rb +0 -190
  63. data/test/test_faker_lorem.rb +0 -87
  64. data/test/test_faker_name.rb +0 -20
  65. data/test/test_faker_number.rb +0 -107
  66. data/test/test_faker_shakespeare.rb +0 -53
  67. data/test/test_faker_slack_emoji.rb +0 -45
  68. data/test/test_faker_star_wars.rb +0 -74
  69. data/test/test_faker_street.rb +0 -58
  70. data/test/test_faker_superhero.rb +0 -16
  71. data/test/test_faker_team.rb +0 -25
  72. data/test/test_faker_time.rb +0 -93
  73. data/test/test_faker_university.rb +0 -20
  74. data/test/test_fi_locale.rb +0 -33
  75. data/test/test_flexible.rb +0 -62
  76. data/test/test_helper.rb +0 -12
  77. data/test/test_locale.rb +0 -47
  78. data/test/test_pl_locale.rb +0 -24
  79. data/test/test_placeholdit.rb +0 -92
  80. data/test/test_pt_locale.rb +0 -27
  81. data/test/test_sv_locale.rb +0 -28
  82. data/test/test_uk_locale.rb +0 -44
@@ -1,47 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- LoadedYaml = ['en', 'en-BORK'].inject({}) do |h, locale|
4
- h[locale] = YAML.load_file(File.expand_path(File.dirname(__FILE__) + "/../lib/locales/#{locale}.yml"))[locale]['faker']
5
- h
6
- end
7
-
8
- class TestLocale < Test::Unit::TestCase
9
- def teardown
10
- Faker::Config.locale = nil
11
- end
12
-
13
- def test_locale_separate_from_i18n
14
- I18n.locale = :en
15
- Faker::Config.locale = :de
16
- assert Faker::PhoneNumber.phone_number.match(/\(0\d+\) \d+|\+49-\d+-\d+/)
17
- assert Faker::Address.street_name.match(//)
18
- Faker::Config.locale = :ru
19
- assert Faker::Internet.domain_name.match(/([\da-z\.-]+)\.([a-z\.]{2,6})/)
20
- end
21
-
22
- def test_configured_locale_translation
23
- Faker::Config.locale = 'en-BORK'
24
- assert_equal Faker::Base.translate('faker.lorem.words').first, LoadedYaml['en-BORK']['lorem']['words'].first
25
- end
26
-
27
- def test_locale_override_when_calling_translate
28
- Faker::Config.locale = 'en-BORK'
29
- assert_equal Faker::Base.translate('faker.lorem.words', :locale => :en).first, LoadedYaml['en']['lorem']['words'].first
30
- end
31
-
32
- def test_translation_fallback
33
- Faker::Config.locale = 'en-BORK'
34
- assert_nil LoadedYaml['en-BORK']['name']
35
- assert_equal Faker::Base.translate('faker.name.first_name').first, LoadedYaml['en']['name']['first_name'].first
36
- end
37
-
38
- def test_regex
39
- Faker::Config.locale = 'en-GB'
40
- re = /[A-PR-UWYZ][A-HK-Y]?[0-9][ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}/
41
- assert re.match(result = Faker::Address.postcode), "#{result} didn't match #{re}"
42
- end
43
-
44
- def test_available_locales
45
- assert I18n.locale_available?('en-GB')
46
- end
47
- end
@@ -1,24 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TestPlLocale < Test::Unit::TestCase
4
- def setup
5
- @phone_prefixes = %w{12 13 14 15 16 17 18 22 23 24 25 29 32 33 34 41 42 43 44 46 48 52 54 55 56 58 59 61 62 63 65 67 68 71 74 75 76 77 81 82 83 84 85 86 87 89 91 94 95}.sort
6
- @cell_prefixes = %w{50 51 53 57 60 66 69 72 73 78 79 88}.sort
7
- @previous_locale = Faker::Config.locale
8
- Faker::Config.locale = :pl
9
- end
10
-
11
- def teardown
12
- Faker::Config.locale = @previous_locale
13
- end
14
-
15
- def test_pl_phone_number
16
- prefixes = (0..999).map { Faker::PhoneNumber.phone_number[0,2] }.uniq.sort
17
- assert_equal @phone_prefixes, prefixes
18
- end
19
-
20
- def test_pl_cell_phone
21
- prefixes = (0..999).map { Faker::PhoneNumber.cell_phone[0,2] }.uniq.sort
22
- assert_equal @cell_prefixes, prefixes
23
- end
24
- end
@@ -1,92 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TestPlaceholdit < Test::Unit::TestCase
4
- def setup
5
- @tester = Faker::Placeholdit
6
- end
7
-
8
- def test_placeholdit
9
- assert @tester.image.match(/https:\/\/placehold\.it\/(.+)(png?)/)[1] != nil
10
- end
11
-
12
- def test_avatar_with_custom_size
13
- assert @tester.image('3x3').match(/https:\/\/placehold\.it\/+(\d+x\d+)/)[1] == '3x3'
14
- end
15
-
16
- def test_avatar_with_incorrect_size
17
- assert_raise ArgumentError do
18
- @tester.image('300x300s')
19
- end
20
- end
21
-
22
- def test_avatar_with_supported_format
23
- assert @tester.image('300x300', 'jpg').match(/https:\/\/placehold\.it\/(.+)(jpg?)/)
24
- end
25
-
26
- def test_avatar_with_incorrect_format
27
- assert_raise ArgumentError do
28
- @tester.image('300x300', 'wrong_format')
29
- end
30
- end
31
-
32
- def test_avatar_background_with_correct_six_char_hex
33
- assert @tester.image('300x300', 'jpg', 'ffffff').match(/https:\/\/placehold\.it\/(.+)(jpg?)\/ffffff/)
34
- end
35
-
36
- def test_avatar_background_with_correct_three_char_hex
37
- assert @tester.image('300x300', 'jpg', 'fff').match(/https:\/\/placehold\.it\/(.+)(jpg?)\/fff/)
38
- end
39
-
40
- def test_avatar_background_with_wrong_six_char_hex
41
- assert_raise ArgumentError do
42
- @tester.image('300x300', 'jpg', 'fffffz')
43
- end
44
- end
45
-
46
- def test_avatar_background_with_wrong_hex
47
- assert_raise ArgumentError do
48
- @tester.image('300x300', 'jpg', 'ffff4')
49
- end
50
- end
51
-
52
- def test_avatar_background_with_wrong_three_char_hex
53
- assert_raise ArgumentError do
54
- @tester.image('300x300', 'jpg', 'ffz')
55
- end
56
- end
57
-
58
- def test_avatar_font_color_with_correct_six_char_hex
59
- assert @tester.image('300x300', 'jpg', 'ffffff', '000000').match(/https:\/\/placehold\.it\/(.+)(jpg?)\/ffffff\/000000/)
60
- end
61
-
62
- def test_avatar_font_color_with_correct_three_char_hex
63
- assert @tester.image('300x300', 'jpg', 'fff', '000').match(/https:\/\/placehold\.it\/(.+)(jpg?)\/fff/)
64
- end
65
-
66
- def test_avatar_font_color_with_wrong_six_char_hex
67
- assert_raise ArgumentError do
68
- @tester.image('300x300', 'jpg', 'ffffff', '900F0z')
69
- end
70
- end
71
-
72
- def test_avatar_font_color_with_wrong_hex
73
- assert_raise ArgumentError do
74
- @tester.image('300x300', 'jpg', 'ffffff', 'x9')
75
- end
76
- end
77
-
78
- def test_avatar_font_color_with_wrong_three_char_hex
79
- assert_raise ArgumentError do
80
- @tester.image('300x300', 'jpg', 'ffffff', '00p')
81
- end
82
- end
83
-
84
- def test_text_not_present
85
- assert @tester.image('300x300', 'jpg', 'fff', '000').match(/https:\/\/placehold\.it\/[^\\?]+$/)
86
- end
87
-
88
- def test_text_present
89
- assert @tester.image('300x300', 'jpg', 'fff', '000', 'hello').match(/https:\/\/placehold\.it\/(.+)\?text=hello/)
90
- end
91
-
92
- end
@@ -1,27 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TestEsLocale < Test::Unit::TestCase
4
- def setup
5
- Faker::Config.locale = "pt"
6
- end
7
-
8
- def teardown
9
- Faker::Config.locale = nil
10
- end
11
-
12
- def test_pl_phone_number
13
- assert_match /^(\+351)?[\(\)\d\s\-]+$/, Faker::PhoneNumber.phone_number
14
- end
15
-
16
- def test_pl_building_number
17
- assert_match /^[\d]{3,5}$/, Faker::Address.building_number
18
- end
19
-
20
- def test_pl_post_code
21
- assert_match /^[\d]{4}$/, Faker::Address.postcode
22
- end
23
-
24
- def test_pl_secondary_address
25
- assert_match /^[[:word:]]+[\.]? \d{1,3}$/, Faker::Address.secondary_address
26
- end
27
- end
@@ -1,28 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TestSVLocale < Test::Unit::TestCase
4
- def setup
5
- Faker::Config.locale = 'sv'
6
- end
7
-
8
- def teardown
9
- Faker::Config.locale = nil
10
- end
11
-
12
- def test_sv_names
13
- assert Faker::Name.name.is_a? String
14
- assert Faker::Name.first_name.is_a? String
15
- assert Faker::Name.first_name_men.is_a? String
16
- assert Faker::Name.first_name_women.is_a? String
17
- assert Faker::Name.last_name.is_a? String
18
- end
19
-
20
- def test_sv_phone_number
21
- assert Faker::PhoneNumber.cell_phone.match(/^07[036]{1}[\-\s]?\d{3}[\-\s]?\d{4}$/)
22
- assert Faker::PhoneNumber.phone_number.match(/^\d{4}[\s\-]?\d{4,6}$/)
23
- end
24
-
25
- def test_sv_post_code
26
- assert Faker::Address.postcode.match(/^[\d]{5}$/)
27
- end
28
- end
@@ -1,44 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TestUkLocale < Test::Unit::TestCase
4
- def setup
5
- @previous_locale = Faker::Config.locale
6
- Faker::Config.locale = "uk"
7
- end
8
-
9
- def teardown
10
- Faker::Config.locale = @previous_locale
11
- end
12
-
13
- def test_uk_email_at_symbol_is_not_followed_by_dot
14
- assert Faker::Internet.email.match(/.+@[^.].+\.\w+/)
15
- end
16
-
17
- def test_uk_domain_word_returns_latin_chars
18
- assert Faker::Internet.domain_word.match(/^\w+$/)
19
- end
20
-
21
- def test_uk_zipcode_length
22
- assert Faker::Address.zip_code.match(/^\d{5}$/)
23
- end
24
-
25
- def test_uk_street_prefix_returns_true_value
26
- assert_send([Faker::Address, :street_prefix])
27
- end
28
-
29
- def test_uk_city_prefix_absent
30
- assert_equal("", Faker::Address.city_prefix)
31
- end
32
-
33
- def test_uk_city_suffix_absent
34
- assert_equal("", Faker::Address.city_suffix)
35
- end
36
-
37
- def test_uk_states_do_not_have_abbreviations
38
- assert_equal("", Faker::Address.state_abbr)
39
- end
40
-
41
- def test_uk_company_prefix_returns_true_value
42
- assert_send([Faker::Company, :prefix])
43
- end
44
- end