Skip to content

Commit

Permalink
Refactor deprecation for FmaBrotherhood
Browse files Browse the repository at this point in the history
This commit will refactor the changes from `FmaBrotherhood` to
`FullmetalAlchemistBrotherhood` and use `Faker::Deprecator`.
  • Loading branch information
kirkkwang committed Feb 26, 2024
1 parent 838bbf3 commit 50b540f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 148 deletions.
51 changes: 3 additions & 48 deletions lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,6 @@

module Faker
class JapaneseMedia
class FmaBrotherhood < Base
class << self
extend Gem::Deprecate

##
# Produces a character from FmaBrotherhood.
#
# @return [String]
#
# @example
# Faker::JapaneseMedia::FmaBrotherhood.character #=> "Edward Elric"
#
# @faker.version next
def character
fetch('fma_brotherhood.characters')
end
deprecate :character, 'Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.character', 2024, 02

##
# Produces a cities from FmaBrotherhood.
#
# @return [String]
#
# @example
# Faker::JapaneseMedia::FmaBrotherhood.city #=> "Central City"
#
# @faker.version next
def city
fetch('fma_brotherhood.cities')
end
deprecate :city, 'Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.city', 2024, 02

##
# Produces a country from FmaBrotherhood.
#
# @return [String]
#
# @example
# Faker::JapaneseMedia::FmaBrotherhood.country #=> "Xing"
#
# @faker.version next
def country
fetch('fma_brotherhood.countries')
end
deprecate :country, 'Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.country', 2024, 02
end
end

class FullmetalAlchemistBrotherhood < Base
class << self
##
Expand Down Expand Up @@ -92,5 +44,8 @@ def country
end
end
end

include Faker::Deprecator
deprecate_generator('FmaBrotherhood', FullmetalAlchemistBrotherhood)
end
end
78 changes: 0 additions & 78 deletions lib/locales/en/fma_brotherhood.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,21 @@

require_relative '../../test_helper'

class DeprecatedTestFakerFmaBrotherhood < Test::Unit::TestCase
class TestFakerFmaBrotherhood < Test::Unit::TestCase
def setup
@tester = Faker::JapaneseMedia::FmaBrotherhood
end

def test_character
actual_stdout, actual_stderr = capture_output do
@tester.character
end
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/

assert_empty actual_stdout
assert_match(expected_warning, actual_stderr)
assert_match(/\w+/, @tester.character)
end

def test_city
actual_stdout, actual_stderr = capture_output do
@tester.city
end
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/

assert_empty actual_stdout
assert_match(expected_warning, actual_stderr)
assert_match(/\w+/, @tester.city)
end

def test_country
actual_stdout, actual_stderr = capture_output do
@tester.country
end
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/

assert_empty actual_stdout
assert_match(expected_warning, actual_stderr)
assert_match(/\w+/, @tester.country)
end
end

Expand Down

0 comments on commit 50b540f

Please sign in to comment.