ffaker 2.21.0 → 2.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +11 -0
- data/README.md +15 -4
- data/REFERENCE.md +316 -290
- data/Rakefile +9 -40
- data/bin/console +9 -0
- data/ffaker.gemspec +9 -19
- data/lib/ffaker/address_ua.rb +1 -1
- data/lib/ffaker/book.rb +5 -5
- data/lib/ffaker/code.rb +1 -1
- data/lib/ffaker/company.rb +1 -1
- data/lib/ffaker/company_fr.rb +1 -1
- data/lib/ffaker/data/address_de/state +1 -0
- data/lib/ffaker/data/jo_jo/first_names +356 -0
- data/lib/ffaker/data/jo_jo/full_names +225 -0
- data/lib/ffaker/data/jo_jo/last_names +153 -0
- data/lib/ffaker/data/jo_jo/stands +149 -0
- data/lib/ffaker/date.rb +31 -0
- data/lib/ffaker/geolocation.rb +2 -2
- data/lib/ffaker/identification_br.rb +1 -1
- data/lib/ffaker/identification_ec.rb +39 -0
- data/lib/ffaker/identification_es_cl.rb +2 -2
- data/lib/ffaker/identification_es_co.rb +1 -1
- data/lib/ffaker/identification_kr.rb +3 -3
- data/lib/ffaker/identification_pl.rb +4 -4
- data/lib/ffaker/identification_tw.rb +1 -1
- data/lib/ffaker/jo_jo.rb +24 -0
- data/lib/ffaker/name_pl.rb +1 -1
- data/lib/ffaker/number.rb +2 -2
- data/lib/ffaker/ssn_se.rb +2 -2
- data/lib/ffaker/string.rb +1 -1
- data/lib/ffaker/time.rb +3 -3
- data/lib/ffaker/utils/module_utils.rb +4 -5
- data/lib/ffaker/utils/unique_utils.rb +29 -21
- data/lib/ffaker/vehicle.rb +2 -2
- data/lib/{version.rb → ffaker/version.rb} +1 -1
- data/lib/ffaker.rb +7 -4
- data/test/helper.rb +2 -4
- data/test/test_address_da.rb +3 -3
- data/test/test_address_fi.rb +2 -2
- data/test/test_address_se.rb +2 -2
- data/test/test_cheesy_lingo.rb +1 -1
- data/test/test_color.rb +3 -3
- data/test/test_date.rb +37 -0
- data/test/test_filesystem.rb +3 -3
- data/test/test_freedom_ipsum.rb +1 -1
- data/test/test_gender_it.rb +1 -1
- data/test/test_gender_ja.rb +1 -1
- data/test/test_gender_jp.rb +1 -1
- data/test/test_gender_pl.rb +1 -1
- data/test/test_healthcare_ru.rb +1 -1
- data/test/test_hipster_ipsum.rb +1 -1
- data/test/test_html_ipsum.rb +2 -2
- data/test/test_identification_ec.rb +33 -0
- data/test/test_identification_es_mx.rb +1 -1
- data/test/test_internet_se.rb +2 -1
- data/test/test_jo_jo.rb +29 -0
- data/test/test_lorem_br.rb +1 -1
- data/test/test_lorem_cn.rb +3 -3
- data/test/test_lorem_fr.rb +3 -3
- data/test/test_lorem_ie.rb +2 -2
- data/test/test_lorem_kr.rb +3 -3
- data/test/test_lorem_pl.rb +2 -2
- data/test/test_lorem_ru.rb +3 -3
- data/test/test_lorem_ua.rb +3 -3
- data/test/test_module_utils.rb +33 -0
- data/test/test_name_da.rb +1 -1
- data/test/test_name_ph.rb +1 -1
- data/test/test_name_ru.rb +2 -2
- data/test/test_name_ua.rb +2 -2
- data/test/test_phone_number_se.rb +1 -1
- data/test/test_phone_number_sg.rb +8 -8
- data/test/test_unique_utils.rb +25 -5
- data/test/test_vehicle.rb +22 -0
- metadata +19 -198
data/lib/ffaker/name_pl.rb
CHANGED
@@ -11,7 +11,7 @@ module FFaker
|
|
11
11
|
GENDERS = %i[random female male].freeze
|
12
12
|
MALE_PREFIXES = %w[Pan].freeze
|
13
13
|
FEMALE_PREFIXES = %w[Pani].freeze
|
14
|
-
ACADEMIC_DEGREE_PREFIXES =
|
14
|
+
ACADEMIC_DEGREE_PREFIXES = ['lic.', 'inż.', 'mgr', 'mgr inż.', 'dr', 'dr hab.', 'prof.'].freeze
|
15
15
|
PREFIXES = (MALE_PREFIXES + FEMALE_PREFIXES + ACADEMIC_DEGREE_PREFIXES).freeze
|
16
16
|
|
17
17
|
# Generates a random full name for a given gender (random by default).
|
data/lib/ffaker/number.rb
CHANGED
@@ -18,9 +18,9 @@ module FFaker
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def generate_pattern(digits)
|
21
|
-
raise ArgumentError
|
21
|
+
raise ArgumentError, 'Digits cannot be less than 1' if digits < 1
|
22
22
|
|
23
|
-
"#{fetch_sample(1..9)}#{
|
23
|
+
"#{fetch_sample(1..9)}#{'#' * (digits - 1)}"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/lib/ffaker/ssn_se.rb
CHANGED
@@ -54,7 +54,7 @@ module FFaker
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def random_birth_time_between(from = ::Time.local(1940, 1, 1), to = ::Time.now)
|
57
|
-
::Time.at(from + rand * (to.to_f - from.to_f))
|
57
|
+
::Time.at(from + (rand * (to.to_f - from.to_f)))
|
58
58
|
end
|
59
59
|
|
60
60
|
def random_region_for(gender)
|
@@ -70,7 +70,7 @@ module FFaker
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def random_region_odd
|
73
|
-
rand(0..498) * 2 + 1
|
73
|
+
(rand(0..498) * 2) + 1
|
74
74
|
end
|
75
75
|
|
76
76
|
def three_character_string(number)
|
data/lib/ffaker/string.rb
CHANGED
data/lib/ffaker/time.rb
CHANGED
@@ -25,14 +25,14 @@ module FFaker
|
|
25
25
|
latest_year = params[:year_latest] || 0
|
26
26
|
year = (rand * years_back).ceil + (::DateTime.now.year - latest_year - years_back)
|
27
27
|
month = rand(1..12)
|
28
|
-
day = rand(1
|
28
|
+
day = rand(1..::Date.new(year, month, -1).day)
|
29
29
|
hours = params[:hours] || rand(0..23)
|
30
30
|
minutes = params[:minutes] || rand(0..59)
|
31
31
|
series = [date = ::DateTime.new(year, month, day, hours, minutes)]
|
32
32
|
return date unless params[:series]
|
33
33
|
|
34
34
|
params[:series].each do |some_time_after|
|
35
|
-
series << series.last + (rand * some_time_after).ceil
|
35
|
+
series << (series.last + (rand * some_time_after).ceil)
|
36
36
|
end
|
37
37
|
series
|
38
38
|
end
|
@@ -44,7 +44,7 @@ module FFaker
|
|
44
44
|
def between(from, to)
|
45
45
|
from_value = convert_to_time(from)
|
46
46
|
to_value = convert_to_time(to)
|
47
|
-
::Time.at(from_value + rand * (to_value.to_f - from_value.to_f))
|
47
|
+
::Time.at(from_value + (rand * (to_value.to_f - from_value.to_f)))
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
@@ -25,7 +25,7 @@ module FFaker
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def underscore(string)
|
28
|
-
string.gsub(
|
28
|
+
string.gsub('::', '/')
|
29
29
|
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
30
30
|
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
31
31
|
.tr('-', '_')
|
@@ -33,14 +33,14 @@ module FFaker
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def unique(max_retries = 10_000)
|
36
|
-
|
36
|
+
FFaker::UniqueUtils.add_instance(self, max_retries)
|
37
37
|
end
|
38
38
|
|
39
39
|
# http://en.wikipedia.org/wiki/Luhn_algorithm
|
40
40
|
def luhn_check(number)
|
41
41
|
multiplications = []
|
42
42
|
|
43
|
-
number.split(
|
43
|
+
number.split('').each_with_index do |digit, i|
|
44
44
|
multiplications << i.even? ? digit.to_i * 2 : digit.to_i
|
45
45
|
end
|
46
46
|
|
@@ -51,9 +51,8 @@ module FFaker
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
control_digit = (sum % 10).zero? ? 0 : (sum / 10 + 1) * 10 - sum
|
54
|
+
control_digit = (sum % 10).zero? ? 0 : (((sum / 10) + 1) * 10) - sum
|
55
55
|
control_digit.to_s
|
56
56
|
end
|
57
|
-
|
58
57
|
end
|
59
58
|
end
|
@@ -1,44 +1,52 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'set'
|
3
4
|
|
4
5
|
module FFaker
|
5
6
|
class UniqueUtils
|
6
|
-
|
7
|
-
@generator = generator
|
8
|
-
@max_retries = max_retries
|
9
|
-
@previous_results = Hash.new { |hash, key| hash[key] = Set.new }
|
10
|
-
end
|
7
|
+
RetryLimitExceeded = Class.new(StandardError)
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
class << self
|
10
|
+
def add_instance(generator, max_retries)
|
11
|
+
instances[generator] ||= FFaker::UniqueUtils.new(generator, max_retries)
|
12
|
+
end
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
def instances
|
15
|
+
Thread.current[:ffaker_unique_utils] ||= {}
|
16
|
+
end
|
19
17
|
|
20
|
-
|
18
|
+
def clear
|
19
|
+
instances.values.each(&:clear)
|
20
|
+
instances.clear
|
21
|
+
end
|
22
|
+
end
|
21
23
|
|
22
|
-
def
|
23
|
-
@
|
24
|
+
def initialize(generator, max_retries)
|
25
|
+
@generator = generator
|
26
|
+
@max_retries = max_retries
|
24
27
|
end
|
25
28
|
|
26
|
-
def
|
27
|
-
|
29
|
+
def clear
|
30
|
+
previous_results.clear
|
28
31
|
end
|
29
32
|
|
30
33
|
private
|
31
34
|
|
32
|
-
def
|
35
|
+
def method_missing(name, *arguments)
|
33
36
|
@max_retries.times do
|
34
|
-
result = @generator.
|
37
|
+
result = @generator.public_send(name, *arguments)
|
35
38
|
|
36
|
-
next if
|
39
|
+
next if previous_results[[name, arguments]].include?(result)
|
37
40
|
|
38
|
-
|
41
|
+
previous_results[[name, arguments]] << result
|
39
42
|
return result
|
40
43
|
end
|
41
|
-
|
44
|
+
|
45
|
+
raise RetryLimitExceeded, "Retry limit exceeded for #{name}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def previous_results
|
49
|
+
@previous_results ||= Hash.new { |hash, key| hash[key] = Set.new }
|
42
50
|
end
|
43
51
|
end
|
44
52
|
end
|
data/lib/ffaker/vehicle.rb
CHANGED
@@ -7,7 +7,7 @@ module FFaker
|
|
7
7
|
extend self
|
8
8
|
|
9
9
|
# https://en.wikibooks.org/wiki/Vehicle_Identification_Numbers_(VIN_codes)/World_Manufacturer_Identifier_(WMI)
|
10
|
-
VALID_WMI_REGIONS = [*'A'..'C', *'J'..'Z', *'1'..'9'].freeze
|
10
|
+
VALID_WMI_REGIONS = [*'A'..'C', *'J'..'N', 'P', *'R'..'Z', *'1'..'9'].freeze
|
11
11
|
|
12
12
|
VALID_YEAR_CHARS = %w[
|
13
13
|
5 6 7 8 9 A B C D E F G H J K L M N P R S T V W X Y 1 2 3 4 5 6 7 8 9
|
@@ -53,7 +53,7 @@ module FFaker
|
|
53
53
|
|
54
54
|
# Calculate the Check Digit
|
55
55
|
weighted_sum = generated_vin.chars.each_with_index.sum do |char, idx|
|
56
|
-
(TRANSLITERATION_VALUES[char
|
56
|
+
(TRANSLITERATION_VALUES[char] || char).to_i * POSITION_WEIGHTS[idx]
|
57
57
|
end
|
58
58
|
|
59
59
|
check_digit = weighted_sum % 11
|
data/lib/ffaker.rb
CHANGED
@@ -13,15 +13,15 @@ module FFaker
|
|
13
13
|
HEX = %w[0 1 2 3 4 5 6 7 8 9 A B C D E F].freeze
|
14
14
|
|
15
15
|
def self.hexify(*masks)
|
16
|
-
fetch_sample(masks.flatten).gsub(
|
16
|
+
fetch_sample(masks.flatten).gsub('#') { fetch_sample(HEX) }
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.numerify(*masks)
|
20
|
-
fetch_sample(masks.flatten).gsub(
|
20
|
+
fetch_sample(masks.flatten).gsub('#') { rand(0..9).to_s }
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.letterify(*masks)
|
24
|
-
fetch_sample(masks.flatten).gsub(
|
24
|
+
fetch_sample(masks.flatten).gsub('?') { fetch_sample(LETTERS) }
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.bothify(masks)
|
@@ -82,6 +82,7 @@ module FFaker
|
|
82
82
|
autoload :Conference, 'ffaker/conference'
|
83
83
|
autoload :CoursesFR, 'ffaker/courses_fr'
|
84
84
|
autoload :Currency, 'ffaker/currency'
|
85
|
+
autoload :Date, 'ffaker/date'
|
85
86
|
autoload :DizzleIpsum, 'ffaker/dizzle_ipsum'
|
86
87
|
autoload :Education, 'ffaker/education'
|
87
88
|
autoload :EducationCN, 'ffaker/education_cn'
|
@@ -117,6 +118,7 @@ module FFaker
|
|
117
118
|
autoload :IdentificationMX, 'ffaker/identification_mx'
|
118
119
|
autoload :IdentificationPL, 'ffaker/identification_pl'
|
119
120
|
autoload :IdentificationTW, 'ffaker/identification_tw'
|
121
|
+
autoload :IdentificationEC, 'ffaker/identification_ec'
|
120
122
|
autoload :Image, 'ffaker/image'
|
121
123
|
autoload :Internet, 'ffaker/internet'
|
122
124
|
autoload :InternetSE, 'ffaker/internet_se'
|
@@ -128,6 +130,7 @@ module FFaker
|
|
128
130
|
autoload :JobJA, 'ffaker/job_ja'
|
129
131
|
autoload :JobKR, 'ffaker/job_kr'
|
130
132
|
autoload :JobVN, 'ffaker/job_vn'
|
133
|
+
autoload :JoJo, 'ffaker/jo_jo'
|
131
134
|
autoload :Locale, 'ffaker/locale'
|
132
135
|
autoload :Lorem, 'ffaker/lorem'
|
133
136
|
autoload :LoremAR, 'ffaker/lorem_ar'
|
@@ -212,7 +215,7 @@ module FFaker
|
|
212
215
|
autoload :Unit, 'ffaker/unit'
|
213
216
|
autoload :UnitEnglish, 'ffaker/unit_english'
|
214
217
|
autoload :UnitMetric, 'ffaker/unit_metric'
|
215
|
-
autoload :VERSION, 'version'
|
218
|
+
autoload :VERSION, 'ffaker/version'
|
216
219
|
autoload :Vehicle, 'ffaker/vehicle'
|
217
220
|
autoload :Venue, 'ffaker/venue'
|
218
221
|
autoload :Youtube, 'ffaker/youtube'
|
data/test/helper.rb
CHANGED
@@ -13,16 +13,14 @@ module DeterministicHelper
|
|
13
13
|
# Accepts a block. Executes the block multiple times after resetting
|
14
14
|
# the internal Random Number Generator state and compared the results of
|
15
15
|
# each execution to make sure they are the same.
|
16
|
-
def assert_deterministic(options = {})
|
16
|
+
def assert_deterministic(options = {}, &block)
|
17
17
|
raise ArgumentError, 'Must pass a block' unless block_given?
|
18
18
|
|
19
19
|
options = { message: 'Results are not repeatable' }.merge(options)
|
20
20
|
|
21
21
|
returns = Array.new(2) do
|
22
22
|
FFaker::Random.reset!
|
23
|
-
Array.new(5)
|
24
|
-
yield
|
25
|
-
end
|
23
|
+
Array.new(5, &block)
|
26
24
|
end
|
27
25
|
|
28
26
|
assert(returns.uniq.length == 1, options[:message])
|
data/test/test_address_da.rb
CHANGED
@@ -20,11 +20,11 @@ class TestAddressDA < Test::Unit::TestCase
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_state
|
23
|
-
assert_match(/\A[-ÆØÅæøåa-z
|
23
|
+
assert_match(/\A[-ÆØÅæøåa-z]+\z/i, FFaker::AddressDA.state)
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_kommune
|
27
|
-
assert_match(/\A[-ÆØÅæøåa-z
|
27
|
+
assert_match(/\A[-ÆØÅæøåa-z]+\z/i, FFaker::AddressDA.kommune)
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_region
|
@@ -32,7 +32,7 @@ class TestAddressDA < Test::Unit::TestCase
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_city
|
35
|
-
assert_match(/\A[- ÆØÅæøåla-z
|
35
|
+
assert_match(/\A[- ÆØÅæøåla-z]+\z/i, FFaker::AddressDA.city)
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_street_name
|
data/test/test_address_fi.rb
CHANGED
@@ -5,8 +5,8 @@ require_relative 'helper'
|
|
5
5
|
class TestAddressFI < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
7
7
|
|
8
|
-
ALPHA = /\A\p{Alpha}
|
9
|
-
DIGIT = /\d{1}
|
8
|
+
ALPHA = /\A\p{Alpha}+/
|
9
|
+
DIGIT = /\d{1}/
|
10
10
|
|
11
11
|
assert_methods_are_deterministic(
|
12
12
|
FFaker::AddressFI,
|
data/test/test_address_se.rb
CHANGED
@@ -5,8 +5,8 @@ require_relative 'helper'
|
|
5
5
|
class TestAddressSE < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
7
7
|
|
8
|
-
ALPHA = /\A\p{Alpha}
|
9
|
-
DIGIT = /\d{1}
|
8
|
+
ALPHA = /\A\p{Alpha}+/
|
9
|
+
DIGIT = /\d{1}/
|
10
10
|
|
11
11
|
assert_methods_are_deterministic(
|
12
12
|
FFaker::AddressSE,
|
data/test/test_cheesy_lingo.rb
CHANGED
data/test/test_color.rb
CHANGED
@@ -5,9 +5,9 @@ require_relative 'helper'
|
|
5
5
|
class TestColor < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
7
7
|
|
8
|
-
VALID_RGB_REGEX = /\A([0-9]{1,3})\z
|
9
|
-
VALID_OPACITY_REGEX = /^([0-9].[0-9]{1,2})
|
10
|
-
VALID_PERCENTAGE_REGEX = /^([0-9]{1,3}%)
|
8
|
+
VALID_RGB_REGEX = /\A([0-9]{1,3})\z/
|
9
|
+
VALID_OPACITY_REGEX = /^([0-9].[0-9]{1,2})$/
|
10
|
+
VALID_PERCENTAGE_REGEX = /^([0-9]{1,3}%)$/
|
11
11
|
|
12
12
|
assert_methods_are_deterministic(
|
13
13
|
FFaker::Color,
|
data/test/test_date.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'helper'
|
4
|
+
|
5
|
+
class TestFakerDate < Test::Unit::TestCase
|
6
|
+
include DeterministicHelper
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@tester = FFaker::Date
|
10
|
+
end
|
11
|
+
|
12
|
+
assert_methods_are_deterministic(FFaker::Date, :backward, :forward)
|
13
|
+
|
14
|
+
def test_between
|
15
|
+
from = Date.new(2015, 1, 1)
|
16
|
+
to = Date.new(2016, 12, 31)
|
17
|
+
|
18
|
+
assert_random_between(from..to) { @tester.between(from, to) }
|
19
|
+
assert_instance_of Date, @tester.between(from, to)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_backward
|
23
|
+
today = Date.today
|
24
|
+
|
25
|
+
assert_random_between(today - 365..today - 1) { @tester.backward }
|
26
|
+
assert_random_between(today - 30..today - 1) { @tester.backward(30) }
|
27
|
+
assert_instance_of Date, @tester.backward
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_forward
|
31
|
+
today = Date.today
|
32
|
+
|
33
|
+
assert_random_between(today + 1..today + 365) { @tester.forward }
|
34
|
+
assert_random_between(today + 1..today + 30) { @tester.forward(30) }
|
35
|
+
assert_instance_of Date, @tester.forward
|
36
|
+
end
|
37
|
+
end
|
data/test/test_filesystem.rb
CHANGED
@@ -15,10 +15,10 @@ class TestFakerFilesystem < Test::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_extension
|
18
|
-
assert_match
|
18
|
+
assert_match(/\A(?:flac|mp3|wav|bmp|gif|jpeg|jpg|png|tiff|css|csv|html|js|
|
19
19
|
json|txt|mp4|avi|mov|webm|doc|docx|xls|xlsx|ppt|pptx|odt|
|
20
20
|
ods|odp|pages|numbers|key|pdf)\z/x,
|
21
|
-
@tester.extension
|
21
|
+
@tester.extension)
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_mime_type_format
|
@@ -31,6 +31,6 @@ class TestFakerFilesystem < Test::Unit::TestCase
|
|
31
31
|
|
32
32
|
def test_file_name
|
33
33
|
assert_match %r{\A(?:[a-z_-]+[\\/])+[a-z_-]+\.\w{2,4}\z},
|
34
|
-
|
34
|
+
@tester.file_name
|
35
35
|
end
|
36
36
|
end
|
data/test/test_freedom_ipsum.rb
CHANGED
data/test/test_gender_it.rb
CHANGED
data/test/test_gender_ja.rb
CHANGED
data/test/test_gender_jp.rb
CHANGED
data/test/test_gender_pl.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative 'helper'
|
|
5
5
|
class TestFakerGenderPL < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
7
7
|
|
8
|
-
GENDER_REGEX = /\A(kobieta|mężczyzna)\z
|
8
|
+
GENDER_REGEX = /\A(kobieta|mężczyzna)\z/
|
9
9
|
|
10
10
|
assert_methods_are_deterministic(FFaker::GenderPL, :random)
|
11
11
|
|
data/test/test_healthcare_ru.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative 'helper'
|
|
5
5
|
class TestHealthcareRU < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
7
7
|
|
8
|
-
SPECIALIZATION_REGEX = /\A[А-Яа-я\ ()\-]+\z
|
8
|
+
SPECIALIZATION_REGEX = /\A[А-Яа-я\ ()\-]+\z/
|
9
9
|
|
10
10
|
assert_methods_are_deterministic(FFaker::HealthcareRU, :doctor_specialization)
|
11
11
|
|
data/test/test_hipster_ipsum.rb
CHANGED
@@ -10,7 +10,7 @@ class TestHipsterIpsum < Test::Unit::TestCase
|
|
10
10
|
:paragraph, :paragraphs, :sentence, :sentences, :word, :words
|
11
11
|
)
|
12
12
|
|
13
|
-
TEST_REGEX = /\+1|[ a-z]+/i
|
13
|
+
TEST_REGEX = /\+1|[ a-z]+/i
|
14
14
|
|
15
15
|
def test_paragraph
|
16
16
|
assert_match(TEST_REGEX, FFaker::HipsterIpsum.paragraph)
|
data/test/test_html_ipsum.rb
CHANGED
@@ -92,8 +92,8 @@ class TestHTMLIpsum < Test::Unit::TestCase
|
|
92
92
|
|
93
93
|
def test_fancy_string_tags
|
94
94
|
# It returns a string with at least one HTML tag
|
95
|
-
assert_match(%r{(<.*>[\w\s]
|
96
|
-
assert_match(%r{(<.*>[\w\s]
|
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
97
|
end
|
98
98
|
|
99
99
|
def test_fancy_string_breaks
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'helper'
|
4
|
+
|
5
|
+
class TestIdentificationEC < Test::Unit::TestCase
|
6
|
+
include DeterministicHelper
|
7
|
+
|
8
|
+
assert_methods_are_deterministic(FFaker::IdentificationEC, :ci)
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@tester = FFaker::IdentificationEC
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_ci
|
15
|
+
assert_match(/^[0-9]{10}$/, @tester.ci)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_last_digit
|
19
|
+
ci = @tester.ci
|
20
|
+
sum = 0
|
21
|
+
ci[0..8].chars.each_with_index do |char, index|
|
22
|
+
if index.even?
|
23
|
+
multiple = char.to_i * 2
|
24
|
+
sum += multiple > 9 ? multiple - 9 : multiple
|
25
|
+
else
|
26
|
+
sum += char.to_i
|
27
|
+
end
|
28
|
+
end
|
29
|
+
mod = sum % 10
|
30
|
+
mod = 10 - mod if mod > 0
|
31
|
+
assert(ci[9].to_i == mod)
|
32
|
+
end
|
33
|
+
end
|
@@ -22,7 +22,7 @@ class TestIdentificationMX < Test::Unit::TestCase
|
|
22
22
|
|
23
23
|
def test_curp
|
24
24
|
or_curp_states_abbr = FFaker::IdentificationMX::ESTADOS_CURP.join('|')
|
25
|
-
re = /\A[a-z][aeioux][a-z]{2}\d{2}[0-1]\d[0-3]\d[hm](?:#{or_curp_states_abbr})[
|
25
|
+
re = /\A[a-z][aeioux][a-z]{2}\d{2}[0-1]\d[0-3]\d[hm](?:#{or_curp_states_abbr})[bcdfghjklmñpqrstvwxyz]{3}[0-9a-z]\d\z/ui
|
26
26
|
assert_match(re, FFaker::IdentificationMX.curp)
|
27
27
|
end
|
28
28
|
end
|
data/test/test_internet_se.rb
CHANGED
@@ -30,7 +30,8 @@ class TestFakerInternetSE < Test::Unit::TestCase
|
|
30
30
|
|
31
31
|
def test_free_email
|
32
32
|
email = @tester.free_email
|
33
|
-
assert email.match(/.+@(gmail\.com|hotmail\.com|yahoo\.com|spray\.se|passagen\.se)/),
|
33
|
+
assert email.match(/.+@(gmail\.com|hotmail\.com|yahoo\.com|spray\.se|passagen\.se)/),
|
34
|
+
"mail: #{email} does not match"
|
34
35
|
end
|
35
36
|
|
36
37
|
def test_login_user_name
|
data/test/test_jo_jo.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'helper'
|
4
|
+
|
5
|
+
class TestJoJo < Test::Unit::TestCase
|
6
|
+
include DeterministicHelper
|
7
|
+
|
8
|
+
assert_methods_are_deterministic(FFaker::JoJo, :full_name, :first_name, :last_name, :stand)
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@tester = FFaker::JoJo
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_full_name
|
15
|
+
assert_include @tester::FULL_NAMES, @tester.full_name
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_first_name
|
19
|
+
assert_include @tester::FIRST_NAMES, @tester.first_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_last_name
|
23
|
+
assert_include @tester::LAST_NAMES, @tester.last_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_stand
|
27
|
+
assert_include @tester::STANDS, @tester.stand
|
28
|
+
end
|
29
|
+
end
|
data/test/test_lorem_br.rb
CHANGED
@@ -10,7 +10,7 @@ class TestLoremBR < Test::Unit::TestCase
|
|
10
10
|
:paragraph, :sentence, :phrase, :paragraphs, :sentences, :phrases, :words, :word, :characters
|
11
11
|
)
|
12
12
|
|
13
|
-
CHARACTERS = /\A[A-zÀ-ü0-9]+\z/i
|
13
|
+
CHARACTERS = /\A[A-zÀ-ü0-9]+\z/i
|
14
14
|
WORD = /\A[A-zÀ-ü-]+\z/i
|
15
15
|
WORDS = /[ A-zÀ-ü-.]+/i
|
16
16
|
|
data/test/test_lorem_cn.rb
CHANGED
@@ -27,7 +27,7 @@ class TestLoremCN < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_paragraphs_is_an_array
|
30
|
-
assert FFaker::LoremCN.paragraphs.
|
30
|
+
assert FFaker::LoremCN.paragraphs.instance_of?(Array)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_sentences
|
@@ -35,12 +35,12 @@ class TestLoremCN < Test::Unit::TestCase
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_sentences_is_an_array
|
38
|
-
assert FFaker::LoremCN.sentences.
|
38
|
+
assert FFaker::LoremCN.sentences.instance_of?(Array)
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_sentences_via_to_s_produces_string_terminated_with_period
|
42
42
|
string = FFaker::LoremCN.sentences.to_s
|
43
|
-
assert string.
|
43
|
+
assert string.instance_of?(String)
|
44
44
|
assert string =~ /。$/
|
45
45
|
end
|
46
46
|
|
data/test/test_lorem_fr.rb
CHANGED
@@ -10,9 +10,9 @@ class TestLoremFR < Test::Unit::TestCase
|
|
10
10
|
:paragraph, :paragraphs, :sentence, :sentences, :phrase, :phrases, :word, :words
|
11
11
|
)
|
12
12
|
|
13
|
-
REGEX = /\A[ -.ÀÂÉÈÊÎÔÚÛàâéèêîôùûa-z]+\z/i
|
14
|
-
REGEX_WORD = /\A[-ÀÂÉÈÊÎÔÚÛàâéèêîôùûa-z]+\z/i
|
15
|
-
REGEX_WORDS = /\A[ -ÀÂÉÈÊÎÔÚÛàâéèêîôùûa-z]+\z/i
|
13
|
+
REGEX = /\A[ -.ÀÂÉÈÊÎÔÚÛàâéèêîôùûa-z]+\z/i
|
14
|
+
REGEX_WORD = /\A[-ÀÂÉÈÊÎÔÚÛàâéèêîôùûa-z]+\z/i
|
15
|
+
REGEX_WORDS = /\A[ -ÀÂÉÈÊÎÔÚÛàâéèêîôùûa-z]+\z/i
|
16
16
|
|
17
17
|
def test_paragraph
|
18
18
|
assert_match(REGEX, FFaker::LoremFR.paragraph)
|
data/test/test_lorem_ie.rb
CHANGED
@@ -11,8 +11,8 @@ class TestLoremIE < Test::Unit::TestCase
|
|
11
11
|
:phrase, :phrases, :word, :words, :question
|
12
12
|
)
|
13
13
|
|
14
|
-
WORDS_REGEX = /\A[\w\W]+\z/i
|
15
|
-
WORD_REGEX = /\A[áéíóúa-z]+\z/i
|
14
|
+
WORDS_REGEX = /\A[\w\W]+\z/i # spaces, alphanumeric & perioids, etc.
|
15
|
+
WORD_REGEX = /\A[áéíóúa-z]+\z/i
|
16
16
|
|
17
17
|
def test_paragraph
|
18
18
|
assert_match(WORDS_REGEX, FFaker::LoremIE.paragraph)
|