Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require:
plugins:
- rubocop-minitest
- rubocop-rake

Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ source 'https://rubygems.org'
gemspec

gem 'benchmark'
gem 'minitest', '5.25.4'
gem 'minitest', '5.25.5'
gem 'pry', '0.15.2'
gem 'rake', '13.2.1'
gem 'rubocop', '1.73.0'
gem 'rubocop-minitest', '0.37.0'
gem 'rubocop', '1.75.4'
gem 'rubocop-minitest', '0.37.1'
gem 'rubocop-rake', '0.7.1'
gem 'simplecov', '0.22.0'
gem 'test-unit', '3.6.7'
gem 'test-unit', '3.6.8'
gem 'timecop', '0.9.10'
gem 'yard', '0.9.37'
38 changes: 20 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,48 @@ PATH
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
ast (2.4.3)
benchmark (0.4.0)
coderay (1.1.3)
concurrent-ruby (1.3.5)
docile (1.4.0)
docile (1.4.1)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.10.1)
json (2.11.3)
language_server-protocol (3.17.0.4)
lint_roller (1.1.0)
method_source (1.1.0)
minitest (5.25.4)
parallel (1.26.3)
parser (3.3.7.1)
minitest (5.25.5)
parallel (1.27.0)
parser (3.3.8.0)
ast (~> 2.4.1)
racc
power_assert (2.0.5)
prism (1.4.0)
pry (0.15.2)
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.10.0)
rubocop (1.73.0)
rubocop (1.75.4)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-ast (>= 1.44.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.38.1)
parser (>= 3.3.1.0)
rubocop-minitest (0.37.0)
rubocop-ast (1.44.1)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-minitest (0.37.1)
lint_roller (~> 1.1)
rubocop (>= 1.61, < 2.0)
rubocop (>= 1.72.1, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-rake (0.7.1)
lint_roller (~> 1.1)
Expand All @@ -56,9 +58,9 @@ GEM
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
test-unit (3.6.7)
test-unit (3.6.8)
power_assert
timecop (0.9.10)
unicode-display_width (3.1.4)
Expand All @@ -73,14 +75,14 @@ PLATFORMS
DEPENDENCIES
benchmark
faker!
minitest (= 5.25.4)
minitest (= 5.25.5)
pry (= 0.15.2)
rake (= 13.2.1)
rubocop (= 1.73.0)
rubocop-minitest (= 0.37.0)
rubocop (= 1.75.4)
rubocop-minitest (= 0.37.1)
rubocop-rake (= 0.7.1)
simplecov (= 0.22.0)
test-unit (= 3.6.7)
test-unit (= 3.6.8)
timecop (= 0.9.10)
yard (= 0.9.37)

Expand Down
4 changes: 4 additions & 0 deletions lib/faker/default/code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def sin

# Reporting body identifier
RBI = %w[01 10 30 33 35 44 45 49 50 51 52 53 54 86 91 98 99].freeze
private_constant :RBI

def generate_imei
str = Array.new(15, 0)
Expand Down Expand Up @@ -269,7 +270,10 @@ def generate_base13_ean
end

EAN_CHECK_DIGIT8 = [3, 1, 3, 1, 3, 1, 3].freeze
private_constant :EAN_CHECK_DIGIT8

EAN_CHECK_DIGIT13 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3].freeze
private_constant :EAN_CHECK_DIGIT13

def rut_verificator_digit(rut)
total = rut.to_s.rjust(8, '0').chars.zip(%w[3 2 7 6 5 4 3 2]).collect { |a, b| a.to_i * b.to_i }.inject(:+)
Expand Down
2 changes: 1 addition & 1 deletion lib/faker/default/driving_licence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def gb_licence_year(dob, gender)
end
g.computed do
gender_marker = gender == :female ? 50 : 0
format('%02d', (dob.month + gender_marker))
format('%02d', dob.month + gender_marker)
end
g.computed do
format('%02d', dob.day)
Expand Down
2 changes: 1 addition & 1 deletion lib/faker/default/internet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def domain_suffix(safe: nil)
# Faker::Internet.mac_address(prefix: 'aa:44') #=> "aa:44:30:88:6e:95"
def mac_address(prefix: '')
prefix_digits = prefix.split(':').map { |d| d.to_i(16) }
address_digits = Array.new((6 - prefix_digits.size)) { rand(256) }
address_digits = Array.new(6 - prefix_digits.size) { rand(256) }
(prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':')
end

Expand Down
2 changes: 1 addition & 1 deletion lib/faker/default/placeholdit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def image(size: '300x300', format: 'png', background_color: nil, text_color: nil
private

def generate_color
format('%06x', (rand * 0xffffff))
format('%06x', rand * 0xffffff)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/faker/books/test_lovecraft.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def test_range_count_param
ss = @tester.sentences(number: 2..5)
ps = @tester.paragraphs(number: 2..5)

assert(ws.length >= 2 && ws.length <= 5)
assert(ss.length >= 2 && ss.length <= 5)
assert(ps.length >= 2 && ps.length <= 5)
assert(ws.length.between?(2, 5))
assert(ss.length.between?(2, 5))
assert(ps.length.between?(2, 5))
end

def test_array_count_param
Expand All @@ -69,7 +69,7 @@ def test_words_with_large_count_params
array = @tester.words(number: [250, 500])

assert_equal(500, exact.length)
assert(range.length >= 250 && range.length <= 500)
assert(range.length.between?(250, 500))
assert(array.length == 250 || array.length == 500)
end

Expand Down
6 changes: 3 additions & 3 deletions test/faker/default/test_array_sample_method_compat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ def test_returns_an_array_with_integer_param

assert_kind_of Array, result
assert_equal(2, result.length)
assert_empty((result - source))
assert_empty(result - source)
end

def test_returns_source_array_with_integer_param_equal_or_bigger_than_source_length
source = %w[foo bar]
result = source.sample(2)

assert_kind_of Array, result
assert_predicate((source.sort <=> result.sort), :zero?)
assert_predicate(source.sort <=> result.sort, :zero?)

result = source.sample(3)

assert_kind_of Array, result
assert_predicate((source.sort <=> result.sort), :zero?)
assert_predicate(source.sort <=> result.sort, :zero?)
end

def test_raises_argument_error_with_negative_param
Expand Down
8 changes: 4 additions & 4 deletions test/faker/default/test_faker_company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_australian_business_number
checksum = abn_checksum(abn)

assert_match(/\d{11}/, abn)
assert_predicate((checksum % 89), :zero?)
assert_predicate(checksum % 89, :zero?)
end

def test_profession
Expand Down Expand Up @@ -167,8 +167,8 @@ def test_luhn_algorithm

even_control = "#{even_base}#{even_luhn_complement}"

assert_predicate((luhn_checksum(odd_control) % 10), :zero?)
assert_predicate((luhn_checksum(even_control) % 10), :zero?)
assert_predicate(luhn_checksum(odd_control) % 10, :zero?)
assert_predicate(luhn_checksum(even_control) % 10, :zero?)
end

def test_brazilian_company_number
Expand Down Expand Up @@ -218,7 +218,7 @@ def test_russian_tax_number_checksum
number = base_number[0..-2]
checksum = base_number.chars.last.to_i

assert_predicate((inn_checksum(number) - checksum), :zero?)
assert_predicate(inn_checksum(number) - checksum, :zero?)
end

def test_sic_code
Expand Down
8 changes: 4 additions & 4 deletions test/faker/default/test_faker_hipster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def test_range_count_param
ss = @tester.sentences(number: 2..5)
ps = @tester.paragraphs(number: 2..5)

assert(ws.length >= 2 && ws.length <= 5)
assert(ss.length >= 2 && ss.length <= 5)
assert(ps.length >= 2 && ps.length <= 5)
assert(ws.length.between?(2, 5))
assert(ss.length.between?(2, 5))
assert(ps.length.between?(2, 5))
end

def test_array_count_param
Expand All @@ -83,7 +83,7 @@ def test_words_with_large_count_params
array = @tester.words(number: [250, 500])

assert_equal(500, exact.length)
assert(range.length >= 250 && range.length <= 500)
assert(range.length.between?(250, 500))
assert(array.length == 250 || array.length == 500)
end

Expand Down
2 changes: 1 addition & 1 deletion test/faker/default/test_faker_internet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def test_password_with_no_arguments
assert_match(/[a-z]/, password)
assert_match(/[A-Z]/, password)
assert_match(/[0-9]/, password)
assert_includes((default_min_length..default_max_length), password.length, 'Generated password length is incorrect')
assert_includes(default_min_length..default_max_length, password.length, 'Generated password length is incorrect')
end

def test_password_with_integer_arg
Expand Down
10 changes: 5 additions & 5 deletions test/faker/default/test_faker_lorem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def test_range_count_param
ss = @tester.sentences(number: 2..5)
ps = @tester.paragraphs(number: 2..5)

assert(cs.length >= 2 && cs.length <= 5)
assert(ws.length >= 2 && ws.length <= 5)
assert(ss.length >= 2 && ss.length <= 5)
assert(ps.length >= 2 && ps.length <= 5)
assert(cs.length.between?(2, 5))
assert(ws.length.between?(2, 5))
assert(ss.length.between?(2, 5))
assert(ps.length.between?(2, 5))
end

def test_exclusive_range_count_param
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_words_with_large_count_params
array = @tester.words(number: [250, 500])

assert_equal(500, exact.length)
assert(range.length >= 250 && range.length <= 500)
assert(range.length.between?(250, 500))
assert(array.length == 250 || array.length == 500)
end

Expand Down
2 changes: 1 addition & 1 deletion test/faker/default/test_faker_vehicle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_engine
def test_mileage
mileage = @tester.mileage(min: 5, max: 10)

assert mileage >= 5 && mileage <= 10
assert mileage.between?(5, 10)
end

def test_license_plate
Expand Down
2 changes: 1 addition & 1 deletion test/test_i18n_reload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_faker_i18n

gemfile do
source 'https://rubygems.org'
gem 'minitest', '5.25.4'
gem 'minitest', '5.25.5'
gem 'i18n'
end

Expand Down
10 changes: 5 additions & 5 deletions test/test_pt_br_locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ def test_pt_br_color_methods

assert_kind_of Array, Faker::Color.rgb_color
Faker::Color.rgb_color.each do |value|
assert value >= 0 && value <= 255
assert value.between?(0, 255)
end

assert_kind_of Array, Faker::Color.hsl_color
hue = Faker::Color.hsl_color[0]

assert hue >= 0 && hue <= 360
assert hue.between?(0, 360)
Faker::Color.hsl_color[1..2].each do |value|
assert value >= 0 && value <= 1
assert value.between?(0, 1)
end

assert_kind_of Array, Faker::Color.hsla_color
assert_kind_of Array, Faker::Color.hsl_color
hue = Faker::Color.hsl_color[0]

assert hue >= 0 && hue <= 360
assert hue.between?(0, 360)
Faker::Color.hsl_color[1..3].each do |value|
assert value >= 0 && value <= 1
assert value.between?(0, 1)
end
end

Expand Down