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

Fix tests failing on Ruby 2.7 #1867

Merged
merged 4 commits into from
Dec 19, 2019
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ rvm:
- 2.6.1
- ruby-head
before_install:
- gem install bundler
- yes | gem update --system=3.1.1 --force
- gem install bundler:2.1.1
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
Expand Down
21 changes: 16 additions & 5 deletions test/faker/default/test_faker_birthday_in_leap_year.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,23 @@ def test_birthday_in_leap_year
@tester.birthday
end

assert_raise ArgumentError do
::Date.new(@today.year - @min, @today.month, @today.day)
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 ArgumentError do
::Date.new(@today.year - @max, @today.month, @today.day)
assert_raise Date::Error do
::Date.new(@today.year - @max, @today.month, @today.day)
end
end
end
end
12 changes: 10 additions & 2 deletions test/faker/default/test_faker_id_number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,16 @@ def test_valid_south_african_id_number

def test_invalid_south_african_id_number
sample = @tester.invalid_south_african_id_number
assert_raises ArgumentError do
Date.parse(south_african_id_number_to_date_of_birth_string(sample))

# 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
end
end

Expand Down