Codebase list ruby-faker / 1cad3a5
Add patch to fix failing tests against Ruby 2.7 (Closes: #952080) Lucas Kanashiro 4 years ago
2 changed file(s) with 69 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 From: Lucas Kanashiro <lucas.kanashiro@canonical.com>
1 Date: Wed, 18 Mar 2020 16:33:07 -0300
2 Subject: Fix failing tests against Ruby 2.7
3
4 Two tests expect an ArgumentError exception but in Ruby 2.7 it was
5 changed to Date::Error. This patch is based on this upstream commit:
6
7 https://github.com/faker-ruby/faker/commit/54a1bbfc1e7f92f6230dfeefa893e17edfcb3802
8 ---
9 test/test_faker_birthday_in_leap_year.rb | 21 ++++++++++++++++-----
10 test/test_faker_date.rb | 11 +++++++++--
11 2 files changed, 25 insertions(+), 7 deletions(-)
12
13 diff --git a/test/test_faker_birthday_in_leap_year.rb b/test/test_faker_birthday_in_leap_year.rb
14 index baa59d5..8b262d7 100644
15 --- a/test/test_faker_birthday_in_leap_year.rb
16 +++ b/test/test_faker_birthday_in_leap_year.rb
17 @@ -18,12 +18,23 @@ class TestFakerBirthdayInLeapYear < Test::Unit::TestCase
18 @tester.birthday
19 end
20
21 - assert_raise ArgumentError do
22 - ::Date.new(@today.year - @min, @today.month, @today.day)
23 - end
24 + # The error raised here is changed in Ruby 2.7.
25 + if RUBY_VERSION < '2.7'
26 + assert_raise ArgumentError do
27 + ::Date.new(@today.year - @min, @today.month, @today.day)
28 + end
29 +
30 + assert_raise ArgumentError do
31 + ::Date.new(@today.year - @max, @today.month, @today.day)
32 + end
33 + elsif RUBY_VERSION >= '2.7'
34 + assert_raise Date::Error do
35 + ::Date.new(@today.year - @min, @today.month, @today.day)
36 + end
37
38 - assert_raise ArgumentError do
39 - ::Date.new(@today.year - @max, @today.month, @today.day)
40 + assert_raise Date::Error do
41 + ::Date.new(@today.year - @max, @today.month, @today.day)
42 + end
43 end
44 end
45 end
46 diff --git a/test/test_faker_date.rb b/test/test_faker_date.rb
47 index 7766bc7..ed2c8db 100644
48 --- a/test/test_faker_date.rb
49 +++ b/test/test_faker_date.rb
50 @@ -77,8 +77,15 @@ class TestFakerDate < Test::Unit::TestCase
51 end
52
53 def test_invalid_date
54 - assert_raise ArgumentError do
55 - @tester.between('9999-99-99', '9999-99-99')
56 + # The error raised here is changed in Ruby 2.7.
57 + if RUBY_VERSION < '2.7'
58 + assert_raise ArgumentError do
59 + @tester.between('9999-99-99', '9999-99-99')
60 + end
61 + elsif RUBY_VERSION >= '2.7'
62 + assert_raise Date::Error do
63 + @tester.between('9999-99-99', '9999-99-99')
64 + end
65 end
66 end
67
00 0001-test_middle_name-accept-2-letter-middle-names.patch
11 0002-Specify-available-locales-in-tests.patch
22 0003-tests-turn-relative-paths-into-absolute-ones.patch
3 0004-Fix-failing-tests-against-Ruby-2.7.patch