ffaker 2.22.0 → 2.24.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 +129 -17
- data/Gemfile +15 -0
- data/README.md +3 -2
- data/REFERENCE.md +893 -866
- data/Rakefile +7 -7
- data/ffaker.gemspec +2 -6
- data/lib/ffaker/address.rb +4 -4
- data/lib/ffaker/address_fr.rb +3 -5
- data/lib/ffaker/address_it.rb +1 -4
- data/lib/ffaker/avatar.rb +11 -3
- data/lib/ffaker/bank.rb +1 -1
- data/lib/ffaker/bank_us.rb +37 -0
- data/lib/ffaker/book.rb +10 -2
- data/lib/ffaker/cheesy_lingo.rb +2 -2
- 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/crypto.rb +14 -0
- data/lib/ffaker/date.rb +9 -0
- data/lib/ffaker/filesystem.rb +12 -2
- data/lib/ffaker/guid.rb +7 -1
- data/lib/ffaker/identification_br.rb +2 -11
- data/lib/ffaker/identification_ec.rb +1 -1
- data/lib/ffaker/identification_es_cl.rb +1 -1
- data/lib/ffaker/identification_kr.rb +10 -3
- data/lib/ffaker/identification_pl.rb +2 -2
- data/lib/ffaker/image.rb +28 -4
- data/lib/ffaker/lorem_ja.rb +1 -1
- data/lib/ffaker/lorem_ru.rb +1 -1
- data/lib/ffaker/movie.rb +1 -1
- data/lib/ffaker/name_fr.rb +4 -3
- data/lib/ffaker/name_pl.rb +2 -2
- data/lib/ffaker/number.rb +4 -0
- data/lib/ffaker/phone_number_de.rb +3 -3
- data/lib/ffaker/skill.rb +1 -1
- data/lib/ffaker/ssn.rb +4 -2
- data/lib/ffaker/string.rb +1 -1
- data/lib/ffaker/utils/module_utils.rb +8 -17
- data/lib/ffaker/utils/unique_utils.rb +9 -5
- data/lib/ffaker/uuid.rb +175 -0
- data/lib/ffaker/version.rb +1 -1
- data/lib/ffaker.rb +61 -191
- data/scripts/reference.rb +8 -10
- data/test/helper.rb +5 -5
- data/test/test_avatar.rb +30 -7
- data/test/test_bank_us.rb +37 -0
- data/test/test_book.rb +29 -0
- data/test/test_crypto.rb +15 -0
- data/test/test_date.rb +11 -1
- data/test/test_filesystem.rb +28 -2
- data/test/test_guid.rb +1 -1
- data/test/test_healthcare_ru.rb +1 -1
- data/test/test_identification.rb +12 -2
- data/test/test_identification_ec.rb +1 -1
- data/test/test_identification_es_mx.rb +3 -1
- data/test/test_identification_it.rb +12 -1
- data/test/test_identification_kr.rb +3 -3
- data/test/test_image.rb +51 -5
- data/test/test_internet.rb +3 -1
- data/test/test_internet_se.rb +3 -1
- data/test/test_lorem_br.rb +1 -1
- data/test/test_lorem_ru.rb +1 -1
- data/test/test_lorem_ua.rb +1 -1
- data/test/test_module_utils.rb +9 -0
- data/test/test_name_ua.rb +1 -1
- data/test/test_number.rb +13 -1
- data/test/test_phone_number_nl.rb +1 -1
- data/test/test_unique_utils.rb +4 -0
- data/test/test_units.rb +6 -6
- data/test/test_units_english.rb +15 -15
- data/test/test_units_metric.rb +15 -15
- data/test/test_uuid.rb +73 -0
- metadata +13 -49
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'helper'
|
4
|
+
|
5
|
+
class TestBankUS < Test::Unit::TestCase
|
6
|
+
include DeterministicHelper
|
7
|
+
|
8
|
+
assert_methods_are_deterministic(
|
9
|
+
FFaker::BankUS,
|
10
|
+
:account_number, :routing_number
|
11
|
+
)
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@tester = FFaker::BankUS
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_account_number
|
18
|
+
assert_instance_of String, @tester.account_number
|
19
|
+
assert_match(/\A\d{8}\z/, @tester.account_number(min_digits: 8, max_digits: 8))
|
20
|
+
assert_match(/\A\d{12}\z/, @tester.account_number(min_digits: 12, max_digits: 12))
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_routing_number
|
24
|
+
routing_number = @tester.routing_number
|
25
|
+
assert_match(/\A\d{9}\z/, routing_number)
|
26
|
+
|
27
|
+
assert_true(@tester::ROUTING_NUMBER_PREFIXES.include?(routing_number[0..1]))
|
28
|
+
|
29
|
+
checksum = (
|
30
|
+
(7 * (routing_number[0].to_i + routing_number[3].to_i + routing_number[6].to_i)) +
|
31
|
+
(3 * (routing_number[1].to_i + routing_number[4].to_i + routing_number[7].to_i)) +
|
32
|
+
(9 * (routing_number[2].to_i + routing_number[5].to_i + routing_number[8].to_i))
|
33
|
+
)
|
34
|
+
|
35
|
+
assert_equal(0, checksum % 10, 'The routing number\'s checksum is not a multiple of ten')
|
36
|
+
end
|
37
|
+
end
|
data/test/test_book.rb
CHANGED
@@ -39,6 +39,35 @@ class TestBook < Test::Unit::TestCase
|
|
39
39
|
@tester.cover)
|
40
40
|
end
|
41
41
|
|
42
|
+
def test_cover_with_format
|
43
|
+
assert_match(%r{\Ahttps://robohash\.org/.+\.jpg\?size=300x300\z},
|
44
|
+
@tester.cover(format: 'jpg'))
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_cover_output_with_keyword_arguments
|
48
|
+
output = capture_output do
|
49
|
+
@tester.cover(format: 'jpg')
|
50
|
+
end
|
51
|
+
|
52
|
+
assert_equal ['', ''], output
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_cover_with_slug_as_positional_argument
|
56
|
+
assert_match(%r{\Ahttps://robohash\.org/foobar\.png\?size=300x300\z},
|
57
|
+
@tester.cover('foobar'))
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_cover_output_with_positional_arguments
|
61
|
+
output = capture_output do
|
62
|
+
@tester.cover('foobar')
|
63
|
+
end
|
64
|
+
|
65
|
+
assert_equal(
|
66
|
+
['', "Positional arguments for Book#cover are deprecated. Please use keyword arguments.\n"],
|
67
|
+
output
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
42
71
|
def test_orly_cover
|
43
72
|
assert_match(%r{\Ahttps://orly-appstore\.herokuapp\.com/generate},
|
44
73
|
@tester.orly_cover)
|
data/test/test_crypto.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'helper'
|
4
|
+
|
5
|
+
class TestCrypto < Test::Unit::TestCase
|
6
|
+
include DeterministicHelper
|
7
|
+
|
8
|
+
assert_methods_are_deterministic(FFaker::Crypto, :sha256)
|
9
|
+
|
10
|
+
def test_sha256
|
11
|
+
assert FFaker::Crypto.sha256.is_a?(String)
|
12
|
+
assert FFaker::Crypto.sha256.length == 64
|
13
|
+
assert_match(/\A[a-z\d]{64}\z/, FFaker::Crypto.sha256)
|
14
|
+
end
|
15
|
+
end
|
data/test/test_date.rb
CHANGED
@@ -9,7 +9,7 @@ class TestFakerDate < Test::Unit::TestCase
|
|
9
9
|
@tester = FFaker::Date
|
10
10
|
end
|
11
11
|
|
12
|
-
assert_methods_are_deterministic(FFaker::Date, :backward, :forward)
|
12
|
+
assert_methods_are_deterministic(FFaker::Date, :backward, :forward, :birthday)
|
13
13
|
|
14
14
|
def test_between
|
15
15
|
from = Date.new(2015, 1, 1)
|
@@ -34,4 +34,14 @@ class TestFakerDate < Test::Unit::TestCase
|
|
34
34
|
assert_random_between(today + 1..today + 30) { @tester.forward(30) }
|
35
35
|
assert_instance_of Date, @tester.forward
|
36
36
|
end
|
37
|
+
|
38
|
+
def test_birthday
|
39
|
+
today = Date.today
|
40
|
+
|
41
|
+
assert_random_between(today.prev_year(65).next_day..today.prev_year(18)) { @tester.birthday }
|
42
|
+
assert_random_between(today.prev_year(43).next_day..today.prev_year(42)) do
|
43
|
+
@tester.birthday(min_age: 42, max_age: 42)
|
44
|
+
end
|
45
|
+
assert_instance_of Date, @tester.birthday
|
46
|
+
end
|
37
47
|
end
|
data/test/test_filesystem.rb
CHANGED
@@ -30,7 +30,33 @@ class TestFakerFilesystem < Test::Unit::TestCase
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_file_name
|
33
|
-
assert_match %r{\A(?:[a-z_-]+[\\/])+[a-z_-]+\.\w{2,4}\z},
|
34
|
-
|
33
|
+
assert_match %r{\A(?:[a-z_-]+[\\/])+[a-z_-]+\.\w{2,4}\z}, @tester.file_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_file_name_with_extension
|
37
|
+
assert_match %r{\A(?:[a-z_-]+[\\/])+[a-z_-]+\.rb\z}, @tester.file_name(ext: 'rb')
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_file_name_output_with_keyword_arguments
|
41
|
+
output = capture_output do
|
42
|
+
@tester.file_name(ext: 'rb')
|
43
|
+
end
|
44
|
+
|
45
|
+
assert_equal ['', ''], output
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_file_name_with_directory_as_positional_argument
|
49
|
+
assert_match %r{\Asome_directory/[a-z_-]+\.\w{2,4}\z}, @tester.file_name('some_directory')
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_file_name_output_with_positional_arguments
|
53
|
+
output = capture_output do
|
54
|
+
@tester.file_name('some_directory')
|
55
|
+
end
|
56
|
+
|
57
|
+
assert_equal(
|
58
|
+
['', "Positional arguments for Filesystem#file_name are deprecated. Please use keyword arguments.\n"],
|
59
|
+
output
|
60
|
+
)
|
35
61
|
end
|
36
62
|
end
|
data/test/test_guid.rb
CHANGED
@@ -8,7 +8,7 @@ class TestGuid < Test::Unit::TestCase
|
|
8
8
|
assert_methods_are_deterministic(FFaker::Guid, :guid)
|
9
9
|
|
10
10
|
def test_guid
|
11
|
-
assert_match(
|
11
|
+
assert_match(/\A[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}\z/,
|
12
12
|
FFaker::Guid.guid)
|
13
13
|
end
|
14
14
|
end
|
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[А-Яа-я\ ()
|
8
|
+
SPECIALIZATION_REGEX = /\A[А-Яа-я\ ()-]+\z/
|
9
9
|
|
10
10
|
assert_methods_are_deterministic(FFaker::HealthcareRU, :doctor_specialization)
|
11
11
|
|
data/test/test_identification.rb
CHANGED
@@ -15,7 +15,6 @@ class TestFakerIdentification < Test::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_drivers_license
|
18
|
-
###-###-##-###-#
|
19
18
|
drivers_license_regex = /\A[A-Z]\d{3}-\d{3}-\d{2}-\d{3}-\d{1}\z/
|
20
19
|
assert_match(drivers_license_regex, @tester.drivers_license)
|
21
20
|
end
|
@@ -29,7 +28,18 @@ class TestFakerIdentification < Test::Unit::TestCase
|
|
29
28
|
end
|
30
29
|
|
31
30
|
def test_ethnicity
|
32
|
-
ethnicity_regex = %r{
|
31
|
+
ethnicity_regex = %r{
|
32
|
+
\A(
|
33
|
+
African\ American|
|
34
|
+
Asian/Pacific\ Islander|
|
35
|
+
Caucasian|
|
36
|
+
Hispanic|
|
37
|
+
Native\ American|
|
38
|
+
Multiracial|
|
39
|
+
Other|
|
40
|
+
Prefer\ not\ to\ respond
|
41
|
+
)\z
|
42
|
+
}x
|
33
43
|
assert_match(ethnicity_regex, @tester.ethnicity)
|
34
44
|
end
|
35
45
|
end
|
@@ -22,7 +22,9 @@ 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 =
|
25
|
+
re = /
|
26
|
+
\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
|
27
|
+
/uix
|
26
28
|
assert_match(re, FFaker::IdentificationMX.curp)
|
27
29
|
end
|
28
30
|
end
|
@@ -28,7 +28,18 @@ class TestFakerIdentificationIT < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_ethnicity
|
31
|
-
ethnicity_regex = %r{
|
31
|
+
ethnicity_regex = %r{
|
32
|
+
\A(
|
33
|
+
Afroamericano|
|
34
|
+
Asiatico/isolano\ del\ Pacifico|
|
35
|
+
Caucasico|
|
36
|
+
Ispanico|
|
37
|
+
Nativo\ americano|
|
38
|
+
Multirazziale|
|
39
|
+
Altro|
|
40
|
+
Preferisco\ non\ rispondere
|
41
|
+
)\z
|
42
|
+
}x
|
32
43
|
assert_match(ethnicity_regex, @tester.ethnicity)
|
33
44
|
end
|
34
45
|
end
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
require_relative 'helper'
|
4
4
|
|
5
|
-
class
|
5
|
+
class TestFakerIdentificationKR < Test::Unit::TestCase
|
6
6
|
include DeterministicHelper
|
7
7
|
|
8
|
-
assert_methods_are_deterministic(FFaker::
|
8
|
+
assert_methods_are_deterministic(FFaker::IdentificationKR, :rrn)
|
9
9
|
|
10
10
|
def setup
|
11
|
-
@tester = FFaker::
|
11
|
+
@tester = FFaker::IdentificationKR
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_rrn
|
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
|
data/test/test_internet.rb
CHANGED
@@ -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(
|
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
|
data/test/test_internet_se.rb
CHANGED
@@ -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(
|
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
|
data/test/test_lorem_br.rb
CHANGED
data/test/test_lorem_ru.rb
CHANGED
data/test/test_lorem_ua.rb
CHANGED
@@ -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[
|
10
|
+
WORD_MATCHER = /\A[а-яА-ЯіїєґІЇЄҐ’-]+\z/
|
11
11
|
|
12
12
|
assert_methods_are_deterministic(
|
13
13
|
FFaker::LoremUA,
|
data/test/test_module_utils.rb
CHANGED
@@ -44,4 +44,13 @@ class TestModuleUtils < Test::Unit::TestCase
|
|
44
44
|
FFaker::UniqueUtils.clear
|
45
45
|
generator.unique.test
|
46
46
|
end
|
47
|
+
|
48
|
+
def test_luhn_check
|
49
|
+
obj = Object.new
|
50
|
+
obj.extend FFaker::ModuleUtils
|
51
|
+
assert obj.luhn_check('97248708') == '6'
|
52
|
+
assert obj.luhn_check('1789372997') == '4'
|
53
|
+
assert obj.luhn_check('8899982700037') == '1'
|
54
|
+
assert obj.luhn_check('1234567820001') == '0'
|
55
|
+
end
|
47
56
|
end
|
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[
|
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
|
data/test/test_unique_utils.rb
CHANGED
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
|
17
|
-
@temperature_units = @tester::TEMPERATURE_UNITS
|
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
|
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
|
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
|
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
|
34
|
+
@temperature_units.map { |unit| unit[:abbreviation] },
|
35
35
|
@tester.temperature_abbr
|
36
36
|
end
|
37
37
|
end
|
data/test/test_units_english.rb
CHANGED
@@ -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
|
18
|
-
@mass_units = @tester::MASS_UNITS
|
19
|
-
@liquid_units = @tester::LIQUID_UNITS
|
20
|
-
@volume_units = @tester::VOLUME_UNITS
|
21
|
-
@area_units = @tester::AREA_UNITS
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
61
|
+
assert_include @area_units.map { |unit| unit[:abbreviation] }, @tester.area_abbr
|
62
62
|
end
|
63
63
|
end
|
data/test/test_units_metric.rb
CHANGED
@@ -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
|
18
|
-
@mass_units = @tester::MASS_UNITS
|
19
|
-
@liquid_units = @tester::LIQUID_UNITS
|
20
|
-
@volume_units = @tester::VOLUME_UNITS
|
21
|
-
@area_units = @tester::AREA_UNITS
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
61
|
+
assert_include @area_units.map { |unit| unit[:abbreviation] }, @tester.area_abbr
|
62
62
|
end
|
63
63
|
end
|