ffaker 2.22.0 → 2.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +120 -17
  3. data/Gemfile +15 -0
  4. data/README.md +3 -2
  5. data/REFERENCE.md +885 -868
  6. data/Rakefile +7 -7
  7. data/ffaker.gemspec +2 -6
  8. data/lib/ffaker/address.rb +4 -4
  9. data/lib/ffaker/address_fr.rb +3 -5
  10. data/lib/ffaker/address_it.rb +1 -4
  11. data/lib/ffaker/avatar.rb +11 -3
  12. data/lib/ffaker/bank.rb +1 -1
  13. data/lib/ffaker/bank_us.rb +33 -0
  14. data/lib/ffaker/book.rb +10 -2
  15. data/lib/ffaker/cheesy_lingo.rb +2 -2
  16. data/lib/ffaker/code.rb +1 -1
  17. data/lib/ffaker/company.rb +1 -1
  18. data/lib/ffaker/company_fr.rb +1 -1
  19. data/lib/ffaker/crypto.rb +14 -0
  20. data/lib/ffaker/date.rb +9 -0
  21. data/lib/ffaker/filesystem.rb +12 -2
  22. data/lib/ffaker/identification_br.rb +2 -11
  23. data/lib/ffaker/identification_ec.rb +1 -1
  24. data/lib/ffaker/identification_es_cl.rb +1 -1
  25. data/lib/ffaker/identification_kr.rb +10 -3
  26. data/lib/ffaker/identification_pl.rb +2 -2
  27. data/lib/ffaker/image.rb +28 -4
  28. data/lib/ffaker/lorem_ja.rb +1 -1
  29. data/lib/ffaker/lorem_ru.rb +1 -1
  30. data/lib/ffaker/movie.rb +1 -1
  31. data/lib/ffaker/name_fr.rb +4 -3
  32. data/lib/ffaker/number.rb +4 -0
  33. data/lib/ffaker/phone_number_de.rb +3 -3
  34. data/lib/ffaker/skill.rb +1 -1
  35. data/lib/ffaker/ssn.rb +4 -2
  36. data/lib/ffaker/string.rb +1 -1
  37. data/lib/ffaker/utils/module_utils.rb +2 -2
  38. data/lib/ffaker/utils/unique_utils.rb +9 -5
  39. data/lib/ffaker/version.rb +1 -1
  40. data/lib/ffaker.rb +60 -191
  41. data/scripts/reference.rb +8 -10
  42. data/test/helper.rb +1 -1
  43. data/test/test_avatar.rb +30 -7
  44. data/test/test_bank_us.rb +35 -0
  45. data/test/test_book.rb +29 -0
  46. data/test/test_crypto.rb +15 -0
  47. data/test/test_date.rb +11 -1
  48. data/test/test_filesystem.rb +28 -2
  49. data/test/test_healthcare_ru.rb +1 -1
  50. data/test/test_identification.rb +12 -2
  51. data/test/test_identification_ec.rb +1 -1
  52. data/test/test_identification_es_mx.rb +3 -1
  53. data/test/test_identification_it.rb +12 -1
  54. data/test/test_identification_kr.rb +3 -3
  55. data/test/test_image.rb +51 -5
  56. data/test/test_internet.rb +3 -1
  57. data/test/test_internet_se.rb +3 -1
  58. data/test/test_lorem_br.rb +1 -1
  59. data/test/test_lorem_ru.rb +1 -1
  60. data/test/test_lorem_ua.rb +1 -1
  61. data/test/test_name_ua.rb +1 -1
  62. data/test/test_number.rb +13 -1
  63. data/test/test_phone_number_nl.rb +1 -1
  64. data/test/test_unique_utils.rb +4 -0
  65. data/test/test_units.rb +6 -6
  66. data/test/test_units_english.rb +15 -15
  67. data/test/test_units_metric.rb +15 -15
  68. metadata +7 -45
data/test/test_image.rb CHANGED
@@ -18,34 +18,80 @@ class TestImage < Test::Unit::TestCase
18
18
  @tester.url)
19
19
  end
20
20
 
21
+ def test_url_output_with_keyword_arguments
22
+ output = capture_output do
23
+ @tester.url(format: 'jpg')
24
+ end
25
+
26
+ assert_equal ['', ''], output
27
+ end
28
+
29
+ def test_url_with_size_as_positional_argument
30
+ assert_match(%r(#{Regexp.quote(PLACEHOLDER)}150x320/[0-9a-f]{6}/[0-9a-f]{6}\.png\?text=), @tester.url('150x320'))
31
+ end
32
+
33
+ def test_url_output_with_positional_arguments
34
+ output = capture_output do
35
+ @tester.url('150x320')
36
+ end
37
+
38
+ assert_equal(
39
+ ['', "Positional arguments for Image#url are deprecated. Please use keyword arguments.\n"],
40
+ output
41
+ )
42
+ end
43
+
21
44
  def test_image_url_with_param
22
45
  assert_equal("#{PLACEHOLDER}300x300//.png?text=",
23
- @tester.url('300x300', 'png', nil, nil))
46
+ @tester.url(size: '300x300', format: 'png', bg_color: nil, text_color: nil))
24
47
  end
25
48
 
26
49
  def test_image_url_with_correct_size
27
50
  assert_match(%r(#{Regexp.quote(PLACEHOLDER)}150x320/[0-9a-f]{6}/[0-9a-f]{6}\.png\?text=),
28
- @tester.url('150x320'))
51
+ @tester.url(size: '150x320'))
29
52
  end
30
53
 
31
54
  def test_image_url_with_incorrect_size
32
55
  assert_raise ArgumentError do
33
- @tester.url('150x320z')
56
+ @tester.url(size: '150x320z')
34
57
  end
35
58
  end
36
59
 
37
60
  def test_image_url_with_supported_format
38
61
  assert_match(%r(#{Regexp.quote(PLACEHOLDER)}300x300/[0-9a-f]{6}/[0-9a-f]{6}\.jpg\?text=),
39
- @tester.url('300x300', 'jpg'))
62
+ @tester.url(size: '300x300', format: 'jpg'))
40
63
  end
41
64
 
42
65
  def test_image_url_with_incorrect_format
43
66
  assert_raise ArgumentError do
44
- @tester.url('300x300', 'wrong_format')
67
+ @tester.url(size: '300x300', format: 'wrong_format')
45
68
  end
46
69
  end
47
70
 
48
71
  def test_image_file
49
72
  assert_equal(@tester.file.class.name, 'File')
50
73
  end
74
+
75
+ def test_file_output_with_keyword_arguments
76
+ output = capture_output do
77
+ @tester.file(format: 'jpg')
78
+ end
79
+
80
+ assert_equal ['', ''], output
81
+ end
82
+
83
+ def test_file_with_size_as_positional_argument
84
+ assert_equal(@tester.file('150x320').class.name, 'File')
85
+ end
86
+
87
+ def test_file_output_with_positional_arguments
88
+ output = capture_output do
89
+ @tester.file('150x320')
90
+ end
91
+
92
+ assert_equal(
93
+ ['', "Positional arguments for Image#file are deprecated. Please use keyword arguments.\n"],
94
+ output
95
+ )
96
+ end
51
97
  end
@@ -29,7 +29,9 @@ class TestFakerInternet < Test::Unit::TestCase
29
29
  end
30
30
 
31
31
  def test_disposable_email
32
- assert @tester.disposable_email.match(/.+@(mailinator\.com|suremail\.info|spamherelots\.com|binkmail\.com|safetymail\.info)/)
32
+ assert @tester.disposable_email.match(
33
+ /.+@(mailinator\.com|suremail\.info|spamherelots\.com|binkmail\.com|safetymail\.info)/
34
+ )
33
35
  end
34
36
 
35
37
  def test_safe_email
@@ -25,7 +25,9 @@ class TestFakerInternetSE < Test::Unit::TestCase
25
25
  end
26
26
 
27
27
  def test_disposable_email
28
- assert @tester.disposable_email.match(/.+@(mailinator\.com|suremail\.info|spamherelots\.com|binkmail\.com|safetymail\.info)/)
28
+ assert @tester.disposable_email.match(
29
+ /.+@(mailinator\.com|suremail\.info|spamherelots\.com|binkmail\.com|safetymail\.info)/
30
+ )
29
31
  end
30
32
 
31
33
  def test_free_email
@@ -12,7 +12,7 @@ class TestLoremBR < Test::Unit::TestCase
12
12
 
13
13
  CHARACTERS = /\A[A-zÀ-ü0-9]+\z/i
14
14
  WORD = /\A[A-zÀ-ü-]+\z/i
15
- WORDS = /[ A-zÀ-ü-.]+/i
15
+ WORDS = /[ A-zÀ-ü\-.]+/i
16
16
 
17
17
  def test_paragraph
18
18
  assert_match(WORDS, FFaker::LoremBR.paragraph)
@@ -7,7 +7,7 @@ class TestLoremRU < Test::Unit::TestCase
7
7
 
8
8
  SENTENCE_MATCHER = /\A[а-яА-ЯёЁ\-\s.!?,]+\z/
9
9
  WORDS_MATCHER = /\A[А-Яа-яёЁ\-\s]+\z/
10
- WORD_MATCHER = /\A[А-Яа-яёЁ\-]+\z/
10
+ WORD_MATCHER = /\A[А-Яа-яёЁ-]+\z/
11
11
 
12
12
  assert_methods_are_deterministic(
13
13
  FFaker::LoremRU,
@@ -7,7 +7,7 @@ class TestLoremUA < Test::Unit::TestCase
7
7
 
8
8
  SENTENCE_MATCHER = /\A[а-яА-ЯіїєґІЇЄҐ’\-\s.!?,]+\z/
9
9
  WORDS_MATCHER = /\A[а-яА-ЯіїєґІЇЄҐ’\-\s]+\z/
10
- WORD_MATCHER = /\A[а-яА-ЯіїєґІЇЄҐ’\-]+\z/
10
+ WORD_MATCHER = /\A[а-яА-ЯіїєґІЇЄҐ’-]+\z/
11
11
 
12
12
  assert_methods_are_deterministic(
13
13
  FFaker::LoremUA,
data/test/test_name_ua.rb CHANGED
@@ -15,7 +15,7 @@ class TestNameUA < Test::Unit::TestCase
15
15
  def setup
16
16
  @tester = FFaker::NameUA
17
17
 
18
- @single_word_name_regexp = /\A[а-яА-ЯіїєґІЇЄҐ’\-]+\z/
18
+ @single_word_name_regexp = /\A[а-яА-ЯіїєґІЇЄҐ’-]+\z/
19
19
  @multiple_words_name_regexp = /\A[а-яА-ЯіїєґІЇЄҐ’\-\s]+\z/
20
20
  end
21
21
 
data/test/test_number.rb CHANGED
@@ -5,7 +5,7 @@ require_relative 'helper'
5
5
  class TestNumber < Test::Unit::TestCase
6
6
  include DeterministicHelper
7
7
 
8
- assert_methods_are_deterministic(FFaker::Number, :number, :decimal)
8
+ assert_methods_are_deterministic(FFaker::Number, :number, :decimal, :between)
9
9
 
10
10
  def setup
11
11
  @tester = FFaker::Number
@@ -42,4 +42,16 @@ class TestNumber < Test::Unit::TestCase
42
42
  @tester.decimal(fractional_digits: 0)
43
43
  end
44
44
  end
45
+
46
+ def test_between
47
+ from = -50
48
+ to = 50
49
+ assert_random_between(from..to) { @tester.between(from: from, to: to) }
50
+ assert_instance_of Integer, @tester.between(from: from, to: to)
51
+
52
+ from = -50.0
53
+ to = 50.0
54
+ assert_random_between(from..to) { @tester.between(from: from, to: to) }
55
+ assert_instance_of Float, @tester.between(from: from, to: to)
56
+ end
45
57
  end
@@ -24,7 +24,7 @@ class TestPhoneNumberNL < Test::Unit::TestCase
24
24
 
25
25
  def test_phone_number
26
26
  10.times do
27
- assert_match(/^0([\s\-]*\d){9}$/, @tester.phone_number)
27
+ assert_match(/^0([\s-]*\d){9}$/, @tester.phone_number)
28
28
  end
29
29
  end
30
30
 
@@ -71,4 +71,8 @@ class TestUniqueUtils < Test::Unit::TestCase
71
71
  assert_equal(1, tested_unique_object.test)
72
72
  end
73
73
  end
74
+
75
+ def test_generates_unique_numbers
76
+ assert_nothing_raised { FFaker::Number.unique.number(digits: 1) }
77
+ end
74
78
  end
data/test/test_units.rb CHANGED
@@ -13,25 +13,25 @@ class TestUnits < Test::Unit::TestCase
13
13
 
14
14
  def setup
15
15
  @tester = FFaker::Unit
16
- @time_units = @tester::TIME_UNITS.map { |u| OpenStruct.new u }
17
- @temperature_units = @tester::TEMPERATURE_UNITS.map { |u| OpenStruct.new u }
16
+ @time_units = @tester::TIME_UNITS
17
+ @temperature_units = @tester::TEMPERATURE_UNITS
18
18
  end
19
19
 
20
20
  def test_time_name
21
- assert_include @time_units.map(&:name), @tester.time_name
21
+ assert_include @time_units.map { |unit| unit[:name] }, @tester.time_name
22
22
  end
23
23
 
24
24
  def test_time_abbr
25
- assert_include @time_units.map(&:abbreviation), @tester.time_abbr
25
+ assert_include @time_units.map { |unit| unit[:abbreviation] }, @tester.time_abbr
26
26
  end
27
27
 
28
28
  def test_temperature_name
29
- assert_include @temperature_units.map(&:name), @tester.temperature_name
29
+ assert_include @temperature_units.map { |unit| unit[:name] }, @tester.temperature_name
30
30
  end
31
31
 
32
32
  def test_temperature_abbr
33
33
  assert_include \
34
- @temperature_units.map(&:abbreviation),
34
+ @temperature_units.map { |unit| unit[:abbreviation] },
35
35
  @tester.temperature_abbr
36
36
  end
37
37
  end
@@ -14,50 +14,50 @@ class TestUnitsEnglish < Test::Unit::TestCase
14
14
 
15
15
  def setup
16
16
  @tester = FFaker::UnitEnglish
17
- @length_units = @tester::LENGTH_UNITS.map { |u| OpenStruct.new u }
18
- @mass_units = @tester::MASS_UNITS.map { |u| OpenStruct.new u }
19
- @liquid_units = @tester::LIQUID_UNITS.map { |u| OpenStruct.new u }
20
- @volume_units = @tester::VOLUME_UNITS.map { |u| OpenStruct.new u }
21
- @area_units = @tester::AREA_UNITS.map { |u| OpenStruct.new u }
17
+ @length_units = @tester::LENGTH_UNITS
18
+ @mass_units = @tester::MASS_UNITS
19
+ @liquid_units = @tester::LIQUID_UNITS
20
+ @volume_units = @tester::VOLUME_UNITS
21
+ @area_units = @tester::AREA_UNITS
22
22
  end
23
23
 
24
24
  def test_length_name
25
- assert_include @length_units.map(&:name), @tester.length_name
25
+ assert_include @length_units.map { |unit| unit[:name] }, @tester.length_name
26
26
  end
27
27
 
28
28
  def test_length_abbrev
29
- assert_include @length_units.map(&:abbreviation), @tester.length_abbr
29
+ assert_include @length_units.map { |unit| unit[:abbreviation] }, @tester.length_abbr
30
30
  end
31
31
 
32
32
  def test_mass_name
33
- assert_include @mass_units.map(&:name), @tester.mass_name
33
+ assert_include @mass_units.map { |unit| unit[:name] }, @tester.mass_name
34
34
  end
35
35
 
36
36
  def test_mass_abbr
37
- assert_include @mass_units.map(&:abbreviation), @tester.mass_abbr
37
+ assert_include @mass_units.map { |unit| unit[:abbreviation] }, @tester.mass_abbr
38
38
  end
39
39
 
40
40
  def test_liquid_name
41
- assert_include @liquid_units.map(&:name), @tester.liquid_name
41
+ assert_include @liquid_units.map { |unit| unit[:name] }, @tester.liquid_name
42
42
  end
43
43
 
44
44
  def test_liquid_abbr
45
- assert_include @liquid_units.map(&:abbreviation), @tester.liquid_abbr
45
+ assert_include @liquid_units.map { |unit| unit[:abbreviation] }, @tester.liquid_abbr
46
46
  end
47
47
 
48
48
  def test_volume_name
49
- assert_include @volume_units.map(&:name), @tester.volume_name
49
+ assert_include @volume_units.map { |unit| unit[:name] }, @tester.volume_name
50
50
  end
51
51
 
52
52
  def test_volume_abbr
53
- assert_include @volume_units.map(&:abbreviation), @tester.volume_abbr
53
+ assert_include @volume_units.map { |unit| unit[:abbreviation] }, @tester.volume_abbr
54
54
  end
55
55
 
56
56
  def test_area_name
57
- assert_include @area_units.map(&:name), @tester.area_name
57
+ assert_include @area_units.map { |unit| unit[:name] }, @tester.area_name
58
58
  end
59
59
 
60
60
  def test_area_abbr
61
- assert_include @area_units.map(&:abbreviation), @tester.area_abbr
61
+ assert_include @area_units.map { |unit| unit[:abbreviation] }, @tester.area_abbr
62
62
  end
63
63
  end
@@ -14,50 +14,50 @@ class TestUnitsMetric < Test::Unit::TestCase
14
14
 
15
15
  def setup
16
16
  @tester = FFaker::UnitMetric
17
- @length_units = @tester::LENGTH_UNITS.map { |u| OpenStruct.new u }
18
- @mass_units = @tester::MASS_UNITS.map { |u| OpenStruct.new u }
19
- @liquid_units = @tester::LIQUID_UNITS.map { |u| OpenStruct.new u }
20
- @volume_units = @tester::VOLUME_UNITS.map { |u| OpenStruct.new u }
21
- @area_units = @tester::AREA_UNITS.map { |u| OpenStruct.new u }
17
+ @length_units = @tester::LENGTH_UNITS
18
+ @mass_units = @tester::MASS_UNITS
19
+ @liquid_units = @tester::LIQUID_UNITS
20
+ @volume_units = @tester::VOLUME_UNITS
21
+ @area_units = @tester::AREA_UNITS
22
22
  end
23
23
 
24
24
  def test_length_name
25
- assert_include @length_units.map(&:name), @tester.length_name
25
+ assert_include @length_units.map { |unit| unit[:name] }, @tester.length_name
26
26
  end
27
27
 
28
28
  def test_length_abbrev
29
- assert_include @length_units.map(&:abbreviation), @tester.length_abbr
29
+ assert_include @length_units.map { |unit| unit[:abbreviation] }, @tester.length_abbr
30
30
  end
31
31
 
32
32
  def test_mass_name
33
- assert_include @mass_units.map(&:name), @tester.mass_name
33
+ assert_include @mass_units.map { |unit| unit[:name] }, @tester.mass_name
34
34
  end
35
35
 
36
36
  def test_mass_abbr
37
- assert_include @mass_units.map(&:abbreviation), @tester.mass_abbr
37
+ assert_include @mass_units.map { |unit| unit[:abbreviation] }, @tester.mass_abbr
38
38
  end
39
39
 
40
40
  def test_liquid_name
41
- assert_include @liquid_units.map(&:name), @tester.liquid_name
41
+ assert_include @liquid_units.map { |unit| unit[:name] }, @tester.liquid_name
42
42
  end
43
43
 
44
44
  def test_liquid_abbr
45
- assert_include @liquid_units.map(&:abbreviation), @tester.liquid_abbr
45
+ assert_include @liquid_units.map { |unit| unit[:abbreviation] }, @tester.liquid_abbr
46
46
  end
47
47
 
48
48
  def test_volume_name
49
- assert_include @volume_units.map(&:name), @tester.volume_name
49
+ assert_include @volume_units.map { |unit| unit[:name] }, @tester.volume_name
50
50
  end
51
51
 
52
52
  def test_volume_abbr
53
- assert_include @volume_units.map(&:abbreviation), @tester.volume_abbr
53
+ assert_include @volume_units.map { |unit| unit[:abbreviation] }, @tester.volume_abbr
54
54
  end
55
55
 
56
56
  def test_area_name
57
- assert_include @area_units.map(&:name), @tester.area_name
57
+ assert_include @area_units.map { |unit| unit[:name] }, @tester.area_name
58
58
  end
59
59
 
60
60
  def test_area_abbr
61
- assert_include @area_units.map(&:abbreviation), @tester.area_abbr
61
+ assert_include @area_units.map { |unit| unit[:abbreviation] }, @tester.area_abbr
62
62
  end
63
63
  end
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.22.0
4
+ version: 2.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/ffaker/ffaker/graphs/contributors
@@ -9,50 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-08-23 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rake
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '13.0'
21
- type: :development
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: '13.0'
28
- - !ruby/object:Gem::Dependency
29
- name: rubocop
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: test-unit
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
12
+ date: 2023-09-19 00:00:00.000000000 Z
13
+ dependencies: []
56
14
  description: Ffaker generates dummy data.
57
15
  email: EmmanuelOga@gmail.com
58
16
  executables: []
@@ -110,6 +68,7 @@ files:
110
68
  - lib/ffaker/aws.rb
111
69
  - lib/ffaker/bacon_ipsum.rb
112
70
  - lib/ffaker/bank.rb
71
+ - lib/ffaker/bank_us.rb
113
72
  - lib/ffaker/book.rb
114
73
  - lib/ffaker/boolean.rb
115
74
  - lib/ffaker/cheesy_lingo.rb
@@ -125,6 +84,7 @@ files:
125
84
  - lib/ffaker/company_se.rb
126
85
  - lib/ffaker/conference.rb
127
86
  - lib/ffaker/courses_fr.rb
87
+ - lib/ffaker/crypto.rb
128
88
  - lib/ffaker/currency.rb
129
89
  - lib/ffaker/data/address/city_suffixes
130
90
  - lib/ffaker/data/address/country
@@ -675,6 +635,7 @@ files:
675
635
  - test/test_aws.rb
676
636
  - test/test_bacon_ipsum.rb
677
637
  - test/test_bank.rb
638
+ - test/test_bank_us.rb
678
639
  - test/test_book.rb
679
640
  - test/test_boolean.rb
680
641
  - test/test_cheesy_lingo.rb
@@ -691,6 +652,7 @@ files:
691
652
  - test/test_conference.rb
692
653
  - test/test_course_mathematiques.rb
693
654
  - test/test_course_philosophie.rb
655
+ - test/test_crypto.rb
694
656
  - test/test_currency.rb
695
657
  - test/test_date.rb
696
658
  - test/test_dizzle_ipsum.rb