Skip to content

Commit 50b540f

Browse files
author
Kirk Wang
committed
Refactor deprecation for FmaBrotherhood
This commit will refactor the changes from `FmaBrotherhood` to `FullmetalAlchemistBrotherhood` and use `Faker::Deprecator`.
1 parent 838bbf3 commit 50b540f

File tree

3 files changed

+7
-148
lines changed

3 files changed

+7
-148
lines changed

lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,6 @@
22

33
module Faker
44
class JapaneseMedia
5-
class FmaBrotherhood < Base
6-
class << self
7-
extend Gem::Deprecate
8-
9-
##
10-
# Produces a character from FmaBrotherhood.
11-
#
12-
# @return [String]
13-
#
14-
# @example
15-
# Faker::JapaneseMedia::FmaBrotherhood.character #=> "Edward Elric"
16-
#
17-
# @faker.version next
18-
def character
19-
fetch('fma_brotherhood.characters')
20-
end
21-
deprecate :character, 'Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.character', 2024, 02
22-
23-
##
24-
# Produces a cities from FmaBrotherhood.
25-
#
26-
# @return [String]
27-
#
28-
# @example
29-
# Faker::JapaneseMedia::FmaBrotherhood.city #=> "Central City"
30-
#
31-
# @faker.version next
32-
def city
33-
fetch('fma_brotherhood.cities')
34-
end
35-
deprecate :city, 'Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.city', 2024, 02
36-
37-
##
38-
# Produces a country from FmaBrotherhood.
39-
#
40-
# @return [String]
41-
#
42-
# @example
43-
# Faker::JapaneseMedia::FmaBrotherhood.country #=> "Xing"
44-
#
45-
# @faker.version next
46-
def country
47-
fetch('fma_brotherhood.countries')
48-
end
49-
deprecate :country, 'Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.country', 2024, 02
50-
end
51-
end
52-
535
class FullmetalAlchemistBrotherhood < Base
546
class << self
557
##
@@ -92,5 +44,8 @@ def country
9244
end
9345
end
9446
end
47+
48+
include Faker::Deprecator
49+
deprecate_generator('FmaBrotherhood', FullmetalAlchemistBrotherhood)
9550
end
9651
end

lib/locales/en/fma_brotherhood.yml

Lines changed: 0 additions & 78 deletions
This file was deleted.

test/faker/japanese_media/test_faker_fullmetal_alchemist_brotherhood.rb

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,21 @@
22

33
require_relative '../../test_helper'
44

5-
class DeprecatedTestFakerFmaBrotherhood < Test::Unit::TestCase
5+
class TestFakerFmaBrotherhood < Test::Unit::TestCase
66
def setup
77
@tester = Faker::JapaneseMedia::FmaBrotherhood
88
end
99

1010
def test_character
11-
actual_stdout, actual_stderr = capture_output do
12-
@tester.character
13-
end
14-
expected_warning = /NOTE: Faker::JapaneseMedia::FmaBrotherhood.character is deprecated; use Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.character instead. It will be removed on or after 2024-02.*\n/
15-
16-
assert_empty actual_stdout
17-
assert_match(expected_warning, actual_stderr)
11+
assert_match(/\w+/, @tester.character)
1812
end
1913

2014
def test_city
21-
actual_stdout, actual_stderr = capture_output do
22-
@tester.city
23-
end
24-
expected_warning = /NOTE: Faker::JapaneseMedia::FmaBrotherhood.city is deprecated; use Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.city instead. It will be removed on or after 2024-02.*\n/
25-
26-
assert_empty actual_stdout
27-
assert_match(expected_warning, actual_stderr)
15+
assert_match(/\w+/, @tester.city)
2816
end
2917

3018
def test_country
31-
actual_stdout, actual_stderr = capture_output do
32-
@tester.country
33-
end
34-
expected_warning = /NOTE: Faker::JapaneseMedia::FmaBrotherhood.country is deprecated; use Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.country instead. It will be removed on or after 2024-02.*\n/
35-
36-
assert_empty actual_stdout
37-
assert_match(expected_warning, actual_stderr)
19+
assert_match(/\w+/, @tester.country)
3820
end
3921
end
4022

0 commit comments

Comments
 (0)