Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for EOL Ruby versions (2.5 and 2.6) #2538

Merged
2 changes: 0 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ jobs:
fail-fast: false # don't fail all matrix builds if one fails
matrix:
ruby:
- '2.5'
- '2.6'
- '2.7'
- '3.0'
- '3.1'
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 2.7

Layout/LineLength:
Description: This cop checks the length of lines in the source code. The maximum length is configurable.
Expand Down
2 changes: 1 addition & 1 deletion faker.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
spec.bindir = 'bin'
spec.executables = ['faker']
spec.require_paths = ['lib']
spec.required_ruby_version = '>= 2.5'
spec.required_ruby_version = '>= 2.7'

spec.metadata['changelog_uri'] = 'https://github.com/faker-ruby/faker/blob/master/CHANGELOG.md'
spec.metadata['source_code_uri'] = 'https://github.com/faker-ruby/faker'
Expand Down
2 changes: 1 addition & 1 deletion lib/faker/default/bank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def account_number(legacy_digits = NOT_GIVEN, digits: 10)

output = ''

output += rand.to_s[2..-1] while output.length < digits
output += rand.to_s[2..] while output.length < digits

output[0...digits]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/faker/default/code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def nric(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, ma

birthyear = Date.birthday(min_age: min_age, max_age: max_age).year
prefix = birthyear < 2000 ? 'S' : 'T'
values = birthyear.to_s[-2..-1]
values = birthyear.to_s[-2..]
values << regexify(/\d{5}/)
check_alpha = generate_nric_check_alphabet(values, prefix)
"#{prefix}#{values}#{check_alpha}"
Expand Down
21 changes: 5 additions & 16 deletions test/faker/default/test_faker_birthday_in_leap_year.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,12 @@ def test_birthday_in_leap_year
@tester.birthday
end

# The error raised here is changed in Ruby 2.7.
if RUBY_VERSION < '2.7'
assert_raise ArgumentError do
::Date.new(@today.year - @min, @today.month, @today.day)
end

assert_raise ArgumentError do
::Date.new(@today.year - @max, @today.month, @today.day)
end
elsif RUBY_VERSION >= '2.7'
assert_raise Date::Error do
::Date.new(@today.year - @min, @today.month, @today.day)
end
assert_raise Date::Error do
::Date.new(@today.year - @min, @today.month, @today.day)
end

assert_raise Date::Error do
::Date.new(@today.year - @max, @today.month, @today.day)
end
assert_raise Date::Error do
::Date.new(@today.year - @max, @today.month, @today.day)
end
end
end
11 changes: 2 additions & 9 deletions test/faker/default/test_faker_id_number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,8 @@ def test_valid_south_african_id_number
def test_invalid_south_african_id_number
sample = @tester.invalid_south_african_id_number

# The error raised here is changed in Ruby 2.7.
if RUBY_VERSION < '2.7'
assert_raises ArgumentError do
Date.parse(south_african_id_number_to_date_of_birth_string(sample))
end
elsif RUBY_VERSION >= '2.7'
assert_raises Date::Error do
Date.parse(south_african_id_number_to_date_of_birth_string(sample))
end
assert_raises Date::Error do
Date.parse(south_african_id_number_to_date_of_birth_string(sample))
end
end

Expand Down