ffaker 2.20.0 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
data/scripts/reference.rb CHANGED
@@ -1,30 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../lib/ffaker'
4
+ require 'set'
5
+
6
+ # always use the same seed for consistency
7
+ FFaker::Random.seed = 1337
4
8
 
5
9
  ICONS = {
6
10
  error: '‼️',
7
11
  warning: '❗'
8
12
  }.freeze
9
13
 
14
+ UTILS_MODULES = %i[ArrayUtils ModuleUtils RandomUtils Random]
15
+ UTILS_METHODS = %i[k underscore fetch_sample rand shuffle unique luhn_check]
16
+
10
17
  # Get a list of sections
11
18
  def faker_modules
12
- FFaker.constants.sort.map do |const|
13
- mod = FFaker.const_get(const)
14
- next unless mod.is_a?(Module)
15
- next if mod == FFaker::ArrayUtils
16
- next if mod == FFaker::ModuleUtils
17
- next if mod == FFaker::RandomUtils
18
- next if mod == FFaker::Random
19
-
20
- mod
21
- end.compact
19
+ FFaker
20
+ .constants
21
+ .reject { |const| UTILS_MODULES.include?(const) }
22
+ .select { |const| FFaker.const_get(const).instance_of?(Module) }
23
+ .sort
24
+ .map { |const| FFaker.const_get(const) }
22
25
  end
23
26
 
24
27
  # Returns faker methods for a given module
25
28
  def faker_methods(mod)
26
- methods = mod.methods - Module.methods -
27
- %i[k underscore fetch_sample rand shuffle unique luhn_check]
29
+ methods = mod.methods - Module.methods - UTILS_METHODS
28
30
 
29
31
  # For Company.name (et al), don't discard :name if it was reimplemented
30
32
  methods << :name if mod.send(:name) != mod.to_s
@@ -66,7 +68,7 @@ sections = faker_modules.map do |mod|
66
68
  else
67
69
  begin
68
70
  examples, warnings = catch_warnings do
69
- Array.new(3) { mod.send meth }
71
+ Array.new(3) { mod.unique.send meth }
70
72
  end
71
73
  right = if warnings.any?
72
74
  "#{ICONS[:warning]} *#{warnings.first}*"
@@ -7,7 +7,7 @@ class TestAddressBR < Test::Unit::TestCase
7
7
 
8
8
  assert_methods_are_deterministic(
9
9
  FFaker::AddressBR,
10
- :zip_code, :state, :state_abbr, :city, :street_prefix, :street, :full_address
10
+ :zip_code, :state, :state_abbr, :city, :street_prefix, :street, :complement, :neighborhood, :full_address
11
11
  )
12
12
 
13
13
  def test_zip_code
@@ -32,6 +32,19 @@ class TestAddressBR < Test::Unit::TestCase
32
32
 
33
33
  def test_street
34
34
  prefixes = FFaker::AddressBR::STREET_PREFIX
35
- assert_match(/(#{prefixes.join('|')})( \p{Alpha}+){1,2}/, FFaker::AddressBR.street)
35
+ assert_match(/\A(#{prefixes.join('|')})(?: [\p{Alpha}-]+)+\z/, FFaker::AddressBR.street)
36
+ end
37
+
38
+ def test_complement
39
+ assert_match(/\A(?:Apartamento \d{3}|Casa Térrea|Fundos)\z/, FFaker::AddressBR.complement)
40
+ end
41
+
42
+ def test_neighborhood
43
+ neighborhood_prefix = FFaker::AddressBR.neighborhood.split(' ').first
44
+ assert FFaker::AddressBR::NEIGHBORHOOD_PREFIXES.include?(neighborhood_prefix)
45
+ end
46
+
47
+ def test_full_address
48
+ assert_match(/\A[\p{Alpha}\d, -]+\z/, FFaker::AddressBR.full_address)
36
49
  end
37
50
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helper'
4
+
5
+ class TestAnimalsBR < Test::Unit::TestCase
6
+ include DeterministicHelper
7
+
8
+ assert_methods_are_deterministic(FFaker::AnimalBR, :common_name)
9
+
10
+ def setup
11
+ @tester = FFaker::AnimalBR
12
+ end
13
+
14
+ def test_name
15
+ assert_include @tester::COMMON_NAMES, @tester.common_name
16
+ end
17
+ end
@@ -90,6 +90,12 @@ class TestHTMLIpsum < Test::Unit::TestCase
90
90
  assert FFaker::HTMLIpsum.fancy_string.length > 1, 'the string is longer than one char'
91
91
  end
92
92
 
93
+ def test_fancy_string_tags
94
+ # It returns a string with at least one HTML tag
95
+ assert_match(%r{(<.*>[\w\s]+<\/\w+>){1}}i, FFaker::HTMLIpsum.fancy_string(1))
96
+ assert_match(%r{(<.*>[\w\s]+<\/\w+>){1}}i, FFaker::HTMLIpsum.fancy_string(3))
97
+ end
98
+
93
99
  def test_fancy_string_breaks
94
100
  # We can't reliably predict what's going to end up inside, so just ensure
95
101
  # that we have a complete string.
data/test/test_vehicle.rb CHANGED
@@ -41,7 +41,12 @@ class TestVehicle < Test::Unit::TestCase
41
41
  end
42
42
 
43
43
  def test_vin
44
- assert_match(/\A[A-Z0-9]{17}\z/, FFaker::Vehicle.vin)
44
+ vin = FFaker::Vehicle.vin
45
+
46
+ assert_match(/\A[A-Z0-9]{17}\z/, vin)
47
+ assert_not_match(/[IOQ]/, vin) # VINs can't have these letters
48
+ assert_includes(FFaker::Vehicle::VIN::VALID_ALPHA, vin[6]) # passenger vehicle designator
49
+ assert_includes(FFaker::Vehicle::VIN::VALID_YEAR_CHARS, vin[9]) # check year character
45
50
  end
46
51
 
47
52
  def test_drivetrain
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.20.0
4
+ version: 2.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/ffaker/ffaker/graphs/contributors
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-10-06 00:00:00.000000000 Z
12
+ date: 2022-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -100,6 +100,7 @@ files:
100
100
  - lib/ffaker/address_us.rb
101
101
  - lib/ffaker/airline.rb
102
102
  - lib/ffaker/animal.rb
103
+ - lib/ffaker/animal_br.rb
103
104
  - lib/ffaker/animal_cn.rb
104
105
  - lib/ffaker/animal_es.rb
105
106
  - lib/ffaker/animal_pl.rb
@@ -131,6 +132,8 @@ files:
131
132
  - lib/ffaker/data/address/street_suffix
132
133
  - lib/ffaker/data/address/time_zone
133
134
  - lib/ffaker/data/address_br/city
135
+ - lib/ffaker/data/address_br/complement
136
+ - lib/ffaker/data/address_br/neighborhood_prefixes
134
137
  - lib/ffaker/data/address_br/state
135
138
  - lib/ffaker/data/address_br/state_abbr
136
139
  - lib/ffaker/data/address_ca/city
@@ -235,6 +238,7 @@ files:
235
238
  - lib/ffaker/data/airline/codes_list
236
239
  - lib/ffaker/data/airline/names_list
237
240
  - lib/ffaker/data/animal/common_names
241
+ - lib/ffaker/data/animal_br/common_names
238
242
  - lib/ffaker/data/animal_cn/common_names
239
243
  - lib/ffaker/data/animal_es/common_names
240
244
  - lib/ffaker/data/animal_pl/common_names
@@ -653,6 +657,7 @@ files:
653
657
  - test/test_address_us.rb
654
658
  - test/test_airline.rb
655
659
  - test/test_animal.rb
660
+ - test/test_animal_br.rb
656
661
  - test/test_animal_cn.rb
657
662
  - test/test_animal_es.rb
658
663
  - test/test_animal_pl.rb
@@ -840,193 +845,194 @@ signing_key:
840
845
  specification_version: 2
841
846
  summary: Ffaker generates dummy data.
842
847
  test_files:
843
- - test/test_guid.rb
844
- - test/test_address_mx.rb
845
- - test/test_healthcare_ru.rb
846
- - test/test_address_ch_de.rb
847
- - test/test_name_gr.rb
848
- - test/test_phone_number_cu.rb
849
- - test/test_name_kr.rb
850
- - test/test_gender_pl.rb
851
- - test/test_address_gr.rb
852
- - test/test_boolean.rb
853
- - test/test_job_vn.rb
854
- - test/test_freedom_ipsum.rb
855
- - test/test_gender_kr.rb
856
- - test/test_sport_pl.rb
857
- - test/test_ffaker.rb
858
- - test/test_name_id.rb
859
- - test/test_bank.rb
860
- - test/test_gender_it.rb
861
- - test/test_locale.rb
862
- - test/test_phone_number_id.rb
863
- - test/test_address_it.rb
864
- - test/test_address_fi.rb
848
+ - test/test_internet_se.rb
849
+ - test/test_phone_number_br.rb
865
850
  - test/test_game.rb
851
+ - test/test_lorem_ie.rb
852
+ - test/test_job_cn.rb
853
+ - test/test_unique_utils.rb
866
854
  - test/helper.rb
867
- - test/test_bacon_ipsum.rb
868
- - test/test_name_ar.rb
869
- - test/test_lorem_ar.rb
870
- - test/test_phone_number_sg.rb
871
- - test/test_address_ja.rb
872
- - test/test_name_vn.rb
873
- - test/test_company_fr.rb
874
- - test/test_gender.rb
875
- - test/test_cheesy_lingo.rb
876
- - test/test_geolocation.rb
877
- - test/test_name_th.rb
878
- - test/test_lorem_pl.rb
855
+ - test/test_animal_br.rb
856
+ - test/test_phone_number_ua.rb
857
+ - test/test_healthcare_ipsum.rb
858
+ - test/test_animal_us.rb
879
859
  - test/test_address_ru.rb
880
- - test/test_filesystem.rb
881
- - test/test_name_pl.rb
882
- - test/test_animal_pl.rb
883
- - test/test_name_ga.rb
884
- - test/test_address_br.rb
885
- - test/test_name_de.rb
886
- - test/test_address.rb
887
- - test/test_phone_number_pl.rb
888
- - test/test_phone_number_br.rb
889
- - test/test_phone_number_tw.rb
890
- - test/test_hipster_ipsum.rb
891
- - test/test_nato_alphabet.rb
892
- - test/test_name_nl.rb
860
+ - test/test_dizzle_ipsum.rb
893
861
  - test/test_lorem.rb
894
- - test/test_sport_ru.rb
895
- - test/test_movie.rb
896
- - test/test_aws.rb
897
- - test/test_html_ipsum.rb
898
- - test/test_phone_number_au.rb
899
- - test/test_color_pl.rb
900
- - test/test_lorem_cn.rb
901
- - test/test_job_cn.rb
902
- - test/test_name_th_en.rb
862
+ - test/test_name_ph.rb
863
+ - test/test_name_br.rb
864
+ - test/test_identification.rb
865
+ - test/test_phone_number_mx.rb
866
+ - test/test_identification_co.rb
867
+ - test/test_address_in.rb
868
+ - test/test_job_br.rb
903
869
  - test/test_lorem_it.rb
904
- - test/test_identification_es_cl.rb
905
- - test/test_name_fr.rb
906
- - test/test_lorem_kr.rb
907
- - test/test_youtube.rb
908
- - test/test_identification_pl.rb
909
- - test/test_address_ch.rb
870
+ - test/test_company_fr.rb
871
+ - test/test_address_uk.rb
872
+ - test/test_skill.rb
873
+ - test/test_job_ja.rb
874
+ - test/test_conference.rb
875
+ - test/test_name_mx.rb
876
+ - test/test_book.rb
877
+ - test/test_phone_number_nl.rb
878
+ - test/test_identification_br.rb
879
+ - test/test_module_utils.rb
880
+ - test/test_address_id.rb
910
881
  - test/test_course_philosophie.rb
911
- - test/test_ssn.rb
912
- - test/test_job_kr.rb
913
- - test/test_address_de.rb
914
- - test/test_unique_utils.rb
882
+ - test/test_address_au.rb
883
+ - test/test_name_nl.rb
884
+ - test/test_movie.rb
885
+ - test/test_address_it.rb
886
+ - test/test_bank.rb
887
+ - test/test_nato_alphabet.rb
888
+ - test/test_education.rb
889
+ - test/test_color.rb
890
+ - test/test_avatar.rb
891
+ - test/test_sport_pl.rb
892
+ - test/test_phone_number_au.rb
893
+ - test/test_identification_es_mx.rb
894
+ - test/test_venue.rb
895
+ - test/test_gender_pl.rb
896
+ - test/test_address_kr.rb
897
+ - test/test_name_nb.rb
898
+ - test/test_identification_kr.rb
899
+ - test/test_company_ja.rb
900
+ - test/test_address_ch_it.rb
901
+ - test/test_address.rb
915
902
  - test/test_code.rb
916
- - test/test_name_es.rb
917
- - test/test_phone_number.rb
918
- - test/test_phone_number_ru.rb
919
- - test/test_phone_number_fr.rb
920
- - test/test_name_sn.rb
921
- - test/test_company.rb
922
- - test/test_address_nl.rb
903
+ - test/test_name.rb
904
+ - test/test_animal_cn.rb
905
+ - test/test_identification_pl.rb
923
906
  - test/test_address_ca.rb
924
- - test/test_number.rb
925
- - test/test_phone_number_nl.rb
907
+ - test/test_identification_it.rb
908
+ - test/test_animal.rb
909
+ - test/test_identification_es_cl.rb
910
+ - test/test_gender_kr.rb
911
+ - test/test_identification_es.rb
912
+ - test/test_name_gr.rb
913
+ - test/test_name_cn.rb
926
914
  - test/test_gender_id.rb
927
- - test/test_address_fr.rb
928
- - test/test_book.rb
929
- - test/test_identification_kr.rb
930
- - test/test_phone_number_se.rb
931
- - test/test_phone_number_sn.rb
932
- - test/test_gender_ru.rb
933
- - test/test_string.rb
934
- - test/test_lorem_ru.rb
935
- - test/test_address_in.rb
936
- - test/test_lorem_br.rb
915
+ - test/test_job_fr.rb
916
+ - test/test_company_cn.rb
937
917
  - test/test_ssn_mx.rb
938
- - test/test_sem_ver.rb
939
- - test/test_address_ua.rb
940
- - test/test_name_cn.rb
941
- - test/test_color_ua.rb
942
- - test/test_identification_es.rb
918
+ - test/test_phone_number_sg.rb
919
+ - test/test_boolean.rb
920
+ - test/test_phone_number_cu.rb
921
+ - test/test_music.rb
922
+ - test/test_sports.rb
923
+ - test/test_name_pl.rb
943
924
  - test/test_currency.rb
944
- - test/test_lorem_fr.rb
945
- - test/test_education_cn.rb
946
- - test/test_identification_it.rb
925
+ - test/test_guid.rb
926
+ - test/test_address_ja.rb
927
+ - test/test_address_br.rb
928
+ - test/test_phone_number_de.rb
929
+ - test/test_aws.rb
930
+ - test/test_phone_number_da.rb
931
+ - test/test_internet.rb
932
+ - test/test_address_fr.rb
933
+ - test/test_phone_number_ja.rb
934
+ - test/test_name_ar.rb
935
+ - test/test_gender_br.rb
936
+ - test/test_products.rb
937
+ - test/test_name_id.rb
947
938
  - test/test_name_kh.rb
948
- - test/test_name_mx.rb
949
- - test/test_sport_us.rb
939
+ - test/test_animal_es.rb
940
+ - test/test_array_utils.rb
941
+ - test/test_animal_pl.rb
942
+ - test/test_time.rb
943
+ - test/test_phone_number_it.rb
950
944
  - test/test_job_it.rb
951
- - test/test_lorem_ja.rb
945
+ - test/test_name_th_en.rb
946
+ - test/test_phone_number_ru.rb
952
947
  - test/test_food.rb
953
- - test/test_company_it.rb
954
- - test/test_internet.rb
955
- - test/test_food_pl.rb
956
- - test/test_color.rb
957
- - test/test_avatar.rb
958
- - test/test_time.rb
959
- - test/test_address_id.rb
960
- - test/test_address_kr.rb
961
- - test/test_phone_number_de.rb
948
+ - test/test_sport_ru.rb
949
+ - test/test_identification_tw.rb
950
+ - test/test_education_cn.rb
951
+ - test/test_image.rb
952
+ - test/test_lorem_kr.rb
953
+ - test/test_identification_in.rb
954
+ - test/test_address_pl.rb
955
+ - test/test_name_es.rb
956
+ - test/test_airline.rb
957
+ - test/test_phone_number_sn.rb
958
+ - test/test_vehicle.rb
959
+ - test/test_job_vn.rb
960
+ - test/test_gender_cn.rb
961
+ - test/test_lorem_ar.rb
962
+ - test/test_html_ipsum.rb
963
+ - test/test_name_da.rb
964
+ - test/test_name_ru.rb
965
+ - test/test_units_metric.rb
966
+ - test/test_address_mx.rb
967
+ - test/test_phone_number_id.rb
968
+ - test/test_number.rb
969
+ - test/test_phone_number_se.rb
970
+ - test/test_ssn.rb
971
+ - test/test_lorem_ru.rb
972
+ - test/test_gender.rb
973
+ - test/test_address_ua.rb
974
+ - test/test_address_gr.rb
975
+ - test/test_color_pl.rb
976
+ - test/test_name_ja.rb
977
+ - test/test_job.rb
978
+ - test/test_healthcare_ru.rb
962
979
  - test/test_tweet.rb
963
- - test/test_job_ja.rb
964
- - test/test_name_se.rb
965
- - test/test_phone_number_mx.rb
966
- - test/test_address_da.rb
980
+ - test/test_color_ua.rb
967
981
  - test/test_name_cs.rb
982
+ - test/test_course_mathematiques.rb
983
+ - test/test_lorem_ja.rb
984
+ - test/test_name_tw.rb
985
+ - test/test_job_kr.rb
986
+ - test/test_address_ch.rb
987
+ - test/test_name_sn.rb
988
+ - test/test_ssn_se.rb
989
+ - test/test_bacon_ipsum.rb
990
+ - test/test_address_fi.rb
991
+ - test/test_phone_number.rb
992
+ - test/test_company_it.rb
993
+ - test/test_sem_ver.rb
994
+ - test/test_address_us.rb
968
995
  - test/test_address_ch_fr.rb
969
- - test/test_gender_jp.rb
970
- - test/test_dizzle_ipsum.rb
996
+ - test/test_lorem_br.rb
997
+ - test/test_units_english.rb
998
+ - test/test_phone_number_pl.rb
999
+ - test/test_name_vn.rb
1000
+ - test/test_gender_ru.rb
1001
+ - test/test_address_ch_de.rb
1002
+ - test/test_filesystem.rb
1003
+ - test/test_freedom_ipsum.rb
971
1004
  - test/test_name_it.rb
972
- - test/test_address_sn.rb
973
- - test/test_name_ja.rb
974
- - test/test_gender_cn.rb
975
- - test/test_company_cn.rb
976
- - test/test_units.rb
977
- - test/test_company_ja.rb
978
- - test/test_name.rb
979
- - test/test_job_fr.rb
980
- - test/test_identification_es_mx.rb
981
- - test/test_address_uk.rb
982
- - test/test_phone_number_da.rb
983
- - test/test_address_ch_it.rb
984
- - test/test_job.rb
985
- - test/test_address_us.rb
1005
+ - test/test_name_th.rb
1006
+ - test/test_gender_it.rb
986
1007
  - test/test_address_se.rb
987
- - test/test_name_ua.rb
988
- - test/test_ssn_se.rb
989
- - test/test_units_metric.rb
990
- - test/test_identification_co.rb
991
- - test/test_animal_cn.rb
1008
+ - test/test_lorem_fr.rb
1009
+ - test/test_string.rb
1010
+ - test/test_locale.rb
1011
+ - test/test_company.rb
1012
+ - test/test_lorem_cn.rb
1013
+ - test/test_sport_us.rb
1014
+ - test/test_name_de.rb
1015
+ - test/test_address_de.rb
992
1016
  - test/test_gender_ja.rb
993
- - test/test_animal_us.rb
994
- - test/test_education.rb
995
- - test/test_phone_number_kr.rb
996
- - test/test_products.rb
997
- - test/test_animal_es.rb
998
- - test/test_address_pl.rb
999
- - test/test_vehicle.rb
1000
- - test/test_gender_br.rb
1001
- - test/test_name_tw.rb
1002
- - test/test_airline.rb
1003
- - test/test_internet_se.rb
1004
- - test/test_phone_number_it.rb
1005
- - test/test_identification_br.rb
1006
- - test/test_music.rb
1007
- - test/test_skill.rb
1008
- - test/test_identification.rb
1009
- - test/test_venue.rb
1010
- - test/test_animal.rb
1011
- - test/test_healthcare_ipsum.rb
1012
- - test/test_conference.rb
1013
- - test/test_company_se.rb
1014
- - test/test_name_nb.rb
1015
- - test/test_identification_in.rb
1016
- - test/test_module_utils.rb
1017
- - test/test_array_utils.rb
1018
- - test/test_units_english.rb
1019
- - test/test_name_br.rb
1020
- - test/test_phone_number_ua.rb
1021
- - test/test_lorem_ie.rb
1022
- - test/test_name_ru.rb
1023
- - test/test_sports.rb
1017
+ - test/test_phone_number_fr.rb
1018
+ - test/test_name_ga.rb
1019
+ - test/test_hipster_ipsum.rb
1020
+ - test/test_phone_number_tw.rb
1021
+ - test/test_lorem_pl.rb
1022
+ - test/test_units.rb
1023
+ - test/test_address_nl.rb
1024
+ - test/test_geolocation.rb
1025
+ - test/test_address_sn.rb
1026
+ - test/test_food_pl.rb
1027
+ - test/test_ffaker.rb
1024
1028
  - test/test_lorem_ua.rb
1025
- - test/test_name_ph.rb
1026
- - test/test_name_da.rb
1027
- - test/test_job_br.rb
1028
- - test/test_identification_tw.rb
1029
- - test/test_image.rb
1030
- - test/test_phone_number_ja.rb
1031
- - test/test_course_mathematiques.rb
1032
- - test/test_address_au.rb
1029
+ - test/test_company_se.rb
1030
+ - test/test_name_fr.rb
1031
+ - test/test_name_kr.rb
1032
+ - test/test_cheesy_lingo.rb
1033
+ - test/test_name_ua.rb
1034
+ - test/test_gender_jp.rb
1035
+ - test/test_name_se.rb
1036
+ - test/test_phone_number_kr.rb
1037
+ - test/test_address_da.rb
1038
+ - test/test_youtube.rb