From 8640f3b33dc5d33106516522fe8feb2c91fdcf50 Mon Sep 17 00:00:00 2001 From: Stefanni Brasil Date: Tue, 15 Oct 2024 19:21:36 -0600 Subject: [PATCH] Removes deprecated generators Preparing for the next release by removing deprecated generators. --- lib/faker/default/id_number.rb | 3 - lib/faker/default/theater.rb | 3 - lib/faker/games/heroes_of_the_storm.rb | 11 - .../fullmetal_alchemist_brotherhood.rb | 3 - lib/faker/locations/australia.rb | 3 - lib/faker/tv_shows/buffy.rb | 13 - lib/faker/tv_shows/dr_who.rb | 13 - .../tv_shows/the_fresh_prince_of_bel_air.rb | 13 - test/faker/default/test_faker_id_number.rb | 289 ------------------ test/faker/default/test_faker_theater.rb | 21 -- ...t_faker_fullmetal_alchemist_brotherhood.rb | 20 -- test/faker/locations/test_faker_australia.rb | 20 -- test/faker/tv_shows/test_buffy.rb | 5 - test/faker/tv_shows/test_dr_who.rb | 6 - .../test_the_fresh_prince_of_bel_air.rb | 5 - 15 files changed, 428 deletions(-) diff --git a/lib/faker/default/id_number.rb b/lib/faker/default/id_number.rb index b02c17b77e..786034e983 100644 --- a/lib/faker/default/id_number.rb +++ b/lib/faker/default/id_number.rb @@ -421,7 +421,4 @@ def _translate(key) end end end - - include Faker::Deprecator - deprecate_generator('IDNumber', IdNumber) end diff --git a/lib/faker/default/theater.rb b/lib/faker/default/theater.rb index b9e8af3db5..03cd237cba 100644 --- a/lib/faker/default/theater.rb +++ b/lib/faker/default/theater.rb @@ -46,7 +46,4 @@ def play end end end - - include Faker::Deprecator - deprecate_generator('Show', Theater) end diff --git a/lib/faker/games/heroes_of_the_storm.rb b/lib/faker/games/heroes_of_the_storm.rb index 2557b3e9bc..89e7955664 100644 --- a/lib/faker/games/heroes_of_the_storm.rb +++ b/lib/faker/games/heroes_of_the_storm.rb @@ -17,17 +17,6 @@ def battleground fetch('heroes_of_the_storm.battlegrounds') end - ## - # This method is deprecated. The implementation will be removed in a near future release. - # Use `HeroesOfTheStorm.class_name` instead. - # - # @deprecated Use {#class_name} instead. - def class - warn '`HeroesOfTheStorm.class` is deprecated. Use `HeroesOfTheStorm.class_name` instead.' - - super - end - ## # Produces a class name from Heroes of the Storm. # diff --git a/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb b/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb index 493cdf51a0..c112eb7255 100644 --- a/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb +++ b/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb @@ -44,8 +44,5 @@ def country end end end - - include Faker::Deprecator - deprecate_generator('FmaBrotherhood', FullmetalAlchemistBrotherhood) end end diff --git a/lib/faker/locations/australia.rb b/lib/faker/locations/australia.rb index e3696d5fa6..a0358b93a5 100644 --- a/lib/faker/locations/australia.rb +++ b/lib/faker/locations/australia.rb @@ -46,7 +46,4 @@ def state end end end - - include Deprecator - deprecate_generator('Australia', Locations::Australia) end diff --git a/lib/faker/tv_shows/buffy.rb b/lib/faker/tv_shows/buffy.rb index 80d21e6568..1848f18194 100644 --- a/lib/faker/tv_shows/buffy.rb +++ b/lib/faker/tv_shows/buffy.rb @@ -45,19 +45,6 @@ def actor fetch('buffy.actors') end - ## - # Produces a actor from Buffy the Vampire Slayer. - # - # @return [String] - # - # @example - # Faker::TvShows::Buffy.celebrity #=> "John Ritter" - # - # @deprecated Use the `actor` method instead. - # - # @faker.version 1.9.2 - alias celebrity actor - ## # Produces a big bad from Buffy the Vampire Slayer. # diff --git a/lib/faker/tv_shows/dr_who.rb b/lib/faker/tv_shows/dr_who.rb index 9951ff3106..b1b9c34bb0 100644 --- a/lib/faker/tv_shows/dr_who.rb +++ b/lib/faker/tv_shows/dr_who.rb @@ -84,19 +84,6 @@ def villain fetch('dr_who.villains') end - ## - # Produces a villain from Doctor Who. - # - # @return [String] - # - # @example - # Faker::TvShows::DrWho.villian #=> "The Master" - # - # @deprecated Use the correctly-spelled `villain` method instead. - # - # @faker.version 1.8.0 - alias villian villain - ## # Produces a species from Doctor Who. # diff --git a/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb b/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb index bead810c33..cf13bf7f51 100644 --- a/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +++ b/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb @@ -32,19 +32,6 @@ def actor fetch('the_fresh_prince_of_bel_air.actors') end - ## - # Produces a actor from The Fresh Prince of Bel-Air. - # - # @return [String] - # - # @example - # Faker::TvShows::TheFreshPrinceOfBelAir.celebrity #=> "Quincy Jones" - # - # @deprecated Use the `actor` method instead. - # - # @faker.version 1.8.3 - alias celebrity actor - ## # Produces a quote from The Fresh Prince of Bel-Air. # diff --git a/test/faker/default/test_faker_id_number.rb b/test/faker/default/test_faker_id_number.rb index 6f3aecd84d..12ceff83c7 100644 --- a/test/faker/default/test_faker_id_number.rb +++ b/test/faker/default/test_faker_id_number.rb @@ -288,292 +288,3 @@ def assert_valid_south_african_id_number(sample) assert Date.parse(south_african_id_number_to_date_of_birth_string(sample)) end end - -class TestFakerIDNumber < Test::Unit::TestCase - def setup - Faker::Deprecator.skip_warning do - @tester = Faker::IDNumber - end - end - - def test_valid_ssn - sample = @tester.valid - - assert_equal(11, sample.length) - assert_equal '-', sample[3] - assert_equal '-', sample[6] - assert sample[0..2].split.map { :to_i }.all? { :is_digit? } - assert sample[4..5].split.map { :to_i }.all? { :is_digit? } - assert sample[7..9].split.map { :to_i }.all? { :is_digit? } - end - - def test_invalid_ssn - sample = @tester.invalid - - assert_equal(11, sample.length) - assert_equal '-', sample[3] - assert_equal '-', sample[6] - assert sample[0..2].split.map { :to_i }.all? { :is_digit? } - assert sample[4..5].split.map { :to_i }.all? { :is_digit? } - assert sample[7..9].split.map { :to_i }.all? { :is_digit? } - end - - def test_spanish_dni - sample = @tester.spanish_citizen_number - - assert_equal 10, sample.length - assert sample[0..7].split.map { :to_i }.all? { :is_digit? } - assert_equal('-', sample[8]) - mod = sample[0..7].to_i % 23 - - assert_equal Faker::IdNumber::CHECKS[mod], sample[9] - end - - def test_spanish_nie - sample = @tester.spanish_foreign_citizen_number - - assert_equal 11, sample.length - assert_includes 'XYZ', sample[0] - assert_equal '-', sample[1] - assert sample[2..8].split.map { :to_i }.all? { :is_digit? } - assert_equal '-', sample[9] - prefix = 'XYZ'.index(sample[0]).to_s - mod = "#{prefix}#{sample[2..8]}".to_i % 23 - - assert_equal Faker::IdNumber::CHECKS[mod], sample[10] - end - - def test_south_african_id_number - assert_valid_south_african_id_number(@tester.south_african_id_number) - end - - def test_valid_south_african_id_number - assert_valid_south_african_id_number(@tester.valid_south_african_id_number) - end - - def test_invalid_south_african_id_number - sample = @tester.invalid_south_african_id_number - - assert_raises Date::Error do - Date.parse(south_african_id_number_to_date_of_birth_string(sample)) - end - end - - def test_brazilian_citizen_number - sample = @tester.brazilian_citizen_number - - assert_match(/^\d{11}$/, sample) - assert_match(/(\d)((?!\1)\d)+/, sample) - end - - def test_brazilian_citizen_number_formatted - sample = @tester.brazilian_citizen_number(formatted: true) - - assert_match(/^\d{3}\.\d{3}\.\d{3}-\d{2}$/, sample) - end - - def test_brazilian_id - sample = @tester.brazilian_id - - assert_match(/^\d{8}(X|\d)?$/, sample) - assert_match(/(\d)((?!\1)\d)+/, sample) - end - - def test_brazilian_id_formatted - sample = @tester.brazilian_id(formatted: true) - - assert_match(/^\d{1,2}.\d{3}.\d{3}-[\dX]$/, sample) - end - - def test_brazilian_citizen_number_checksum_digit - digits = '128991760' - checksum_digit = Faker::IdNumber.send(:brazilian_citizen_number_checksum_digit, digits) - - assert_equal('4', checksum_digit) - digits = '1289917604' - checksum_digit = Faker::IdNumber.send(:brazilian_citizen_number_checksum_digit, digits) - - assert_equal('8', checksum_digit) - end - - def test_brazilian_id_checksum_digit - digits = '41987080' - checksum_digit = Faker::IdNumber.send(:brazilian_id_checksum_digit, digits) - - assert_equal('5', checksum_digit) - end - - def test_brazilian_document_checksum - digits = '123456789' - checksum = Faker::IdNumber.send(:brazilian_document_checksum, digits) - - assert_equal(2100, checksum) - end - - def test_brazilian_document_digit - citizen_number_digit10 = Faker::IdNumber.send(:brazilian_document_digit, 10) - citizen_number_digit_other = Faker::IdNumber.send(:brazilian_document_digit, 9) - id_digit10 = Faker::IdNumber.send(:brazilian_document_digit, 1, id: true) - id_digit11 = Faker::IdNumber.send(:brazilian_document_digit, 0, id: true) - id_digit_other = Faker::IdNumber.send(:brazilian_document_digit, 2, id: true) - - assert_equal('0', citizen_number_digit10) - assert_equal('9', citizen_number_digit_other) - assert_equal('X', id_digit10) - assert_equal('0', id_digit11) - assert_equal('9', id_digit_other) - end - - def test_brazilian_citizen_number_digit - digit10 = Faker::IdNumber.send(:brazilian_citizen_number_digit, 10) - digit_other = Faker::IdNumber.send(:brazilian_citizen_number_digit, 9) - - assert_equal('0', digit10) - assert_equal('9', digit_other) - end - - def test_brazilian_id_digit - digit10 = Faker::IdNumber.send(:brazilian_id_digit, 1) - digit11 = Faker::IdNumber.send(:brazilian_id_digit, 0) - digit_other = Faker::IdNumber.send(:brazilian_id_digit, 2) - - assert_equal('X', digit10) - assert_equal('0', digit11) - assert_equal('9', digit_other) - end - - def test_chilean_id - sample = @tester.chilean_id - - assert_match(/^\d{8}-[K\d]$/, sample) - end - - def test_chilean_verification_code_k - verification_code = Faker::IdNumber.send(:chilean_verification_code, 20_680_873) - - assert_equal('K', verification_code) - end - - def test_chilean_verification_code_0 - verification_code = Faker::IdNumber.send(:chilean_verification_code, 13_196_022) - - assert_equal(0, verification_code) - end - - def test_croatian_id - sample = @tester.croatian_id - - assert_match(/^\d{11}$/, sample) - end - - def test_croatian_id_international - sample = @tester.croatian_id(international: true) - - assert_match(/^HR\d{11}$/, sample) - end - - def test_croatian_id_checksum_digit - digits = '8764670153' - checksum_digit = Faker::IdNumber.send(:croatian_id_checksum_digit, digits) - - assert_equal(5, checksum_digit) - end - - def test_danish_id_number - sample = @tester.danish_id_number - - assert_match(/^\d{10}$/, sample) - end - - def test_french_insee_number - sample = @tester.french_insee_number - - assert_match(/^(?\d{1})(?\d{2})(?\d{2})(?\d{1})(?[0-9AB]{1})(?\d{3})(?\d{3})(?\d{2})$/, sample) - end - - def test_danish_id_number_formatted - sample = @tester.danish_id_number(formatted: true) - - assert_match(/^\d{6}-\d{4}$/, sample) - end - - def test_danish_id_number_birthday - sample = @tester.danish_id_number(birthday: Date.new(1995, 1, 2)) - - assert_match(/^020195\d{4}$/, sample) - end - - def test_danish_id_number_birthday_early_1800 - assert_raises ArgumentError do - @tester.danish_id_number(birthday: Date.new(1815, 1, 2)) - end - end - - def test_danish_id_number_birthday_late_1800 - sample = @tester.danish_id_number(birthday: Date.new(1895, 1, 2)) - - assert_match(/^020195[5678]\d{3}$/, sample) - end - - def test_danish_id_number_birthday_early_1900 - sample = @tester.danish_id_number(birthday: Date.new(1915, 1, 2)) - - assert_match(/^020115[0123]\d{3}$/, sample) - end - - def test_danish_id_number_birthday_late_1900 - sample = @tester.danish_id_number(birthday: Date.new(1995, 1, 2)) - - assert_match(/^020195[012349]\d{3}$/, sample) - end - - def test_danish_id_number_birthday_early_2000 - sample = @tester.danish_id_number(birthday: Date.new(2015, 1, 2)) - - assert_match(/^020115[456789]\d{3}$/, sample) - end - - def test_danish_id_number_birthday_mid_2000 - sample = @tester.danish_id_number(birthday: Date.new(2055, 1, 2)) - - assert_match(/^020155[5678]\d{3}$/, sample) - end - - def test_danish_id_number_birthday_late_2000 - assert_raises ArgumentError do - @tester.danish_id_number(birthday: Date.new(2095, 1, 2)) - end - end - - def test_danish_id_number_gender_female - sample = @tester.danish_id_number(gender: :female) - - assert_predicate sample.chars.last.to_i, :even? - end - - def test_danish_id_number_gender_male - sample = @tester.danish_id_number(gender: :male) - - assert_predicate sample.chars.last.to_i, :odd? - end - - def test_danish_id_number_invalid_gender - assert_raises ArgumentError do - @tester.danish_id_number(gender: :invalid) - end - end - - private - - def south_african_id_number_to_date_of_birth_string(sample) - "19#{sample[0..1]}/#{sample[2..3]}/#{sample[4..5]}}" - end - - def assert_valid_south_african_id_number(sample) - assert_equal 13, sample.length - assert_match(/^\d{13}$/, sample) - assert_include Faker::IdNumber::ZA_CITIZENSHIP_DIGITS, sample[10] - assert_equal Faker::IdNumber::ZA_RACE_DIGIT, sample[11] - assert Date.parse(south_african_id_number_to_date_of_birth_string(sample)) - end -end diff --git a/test/faker/default/test_faker_theater.rb b/test/faker/default/test_faker_theater.rb index bded8c8a59..bf0ad2857f 100644 --- a/test/faker/default/test_faker_theater.rb +++ b/test/faker/default/test_faker_theater.rb @@ -15,24 +15,3 @@ def test_play assert_match(/\w+/, Faker::Theater.play) end end - -# with test_faker_show.rb -class TestFakerShow < Test::Unit::TestCase - def setup - Faker::Deprecator.skip_warning do - @tester = Faker::Show - end - end - - def test_adult_musical - assert_match(/\w+/, @tester.adult_musical) - end - - def test_kids_musical - assert_match(/\w+/, @tester.kids_musical) - end - - def test_play - assert_match(/\w+/, @tester.play) - end -end diff --git a/test/faker/japanese_media/test_faker_fullmetal_alchemist_brotherhood.rb b/test/faker/japanese_media/test_faker_fullmetal_alchemist_brotherhood.rb index f13ae6dde6..d5ac5ac9d3 100644 --- a/test/faker/japanese_media/test_faker_fullmetal_alchemist_brotherhood.rb +++ b/test/faker/japanese_media/test_faker_fullmetal_alchemist_brotherhood.rb @@ -2,26 +2,6 @@ require_relative '../../test_helper' -class TestFakerFmaBrotherhood < Test::Unit::TestCase - def setup - Faker::Deprecator.skip_warning do - @tester = Faker::JapaneseMedia::FmaBrotherhood - end - end - - def test_character - assert_match(/\w+/, @tester.character) - end - - def test_city - assert_match(/\w+/, @tester.city) - end - - def test_country - assert_match(/\w+/, @tester.country) - end -end - class TestFakerFullmetalAlchemistBrotherhood < Test::Unit::TestCase def setup @tester = Faker::JapaneseMedia::FullmetalAlchemistBrotherhood diff --git a/test/faker/locations/test_faker_australia.rb b/test/faker/locations/test_faker_australia.rb index 4cce00fc6e..f6d0f6912e 100644 --- a/test/faker/locations/test_faker_australia.rb +++ b/test/faker/locations/test_faker_australia.rb @@ -15,23 +15,3 @@ def test_state assert_match(/\w+/, Faker::Locations::Australia.state) end end - -class TestFakerAustralia < Test::Unit::TestCase - def setup - Faker::Deprecator.skip_warning do - @tester = Faker::Australia - end - end - - def test_deprecated_location - assert_match(/\w+/, @tester.location) - end - - def test_deprecated_animal - assert_match(/\w+/, @tester.animal) - end - - def test_state - assert_match(/\w+/, @tester.state) - end -end diff --git a/test/faker/tv_shows/test_buffy.rb b/test/faker/tv_shows/test_buffy.rb index b5128ff00e..d9b5b55880 100644 --- a/test/faker/tv_shows/test_buffy.rb +++ b/test/faker/tv_shows/test_buffy.rb @@ -19,11 +19,6 @@ def test_actor assert_match(/\w+/, @tester.actor) end - # deprecated - def test_celebrity - assert_match(/\w+/, @tester.celebrity) - end - def test_big_bad assert_match(/\w+/, @tester.big_bad) end diff --git a/test/faker/tv_shows/test_dr_who.rb b/test/faker/tv_shows/test_dr_who.rb index 57539855bd..7d06713dba 100644 --- a/test/faker/tv_shows/test_dr_who.rb +++ b/test/faker/tv_shows/test_dr_who.rb @@ -28,11 +28,6 @@ def test_quote deterministically_verify(-> { @tester.quote }) { |result| assert_match(/\w+/, result) } end - # deprecated - def test_villian - deterministically_verify(-> { @tester.villian }) { |result| assert_match(/\w+/, result) } - end - def test_villain deterministically_verify(-> { @tester.villain }) { |result| assert_match(/\w+/, result) } end @@ -49,7 +44,6 @@ def test_locales assert_kind_of String, @tester.the_doctor assert_kind_of String, @tester.catch_phrase assert_kind_of String, @tester.quote - assert_kind_of String, @tester.villian # deprecated assert_kind_of String, @tester.villain assert_kind_of String, @tester.specie end diff --git a/test/faker/tv_shows/test_the_fresh_prince_of_bel_air.rb b/test/faker/tv_shows/test_the_fresh_prince_of_bel_air.rb index 44c067e079..f147c2f791 100644 --- a/test/faker/tv_shows/test_the_fresh_prince_of_bel_air.rb +++ b/test/faker/tv_shows/test_the_fresh_prince_of_bel_air.rb @@ -15,11 +15,6 @@ def test_actor assert_match(/\w+/, @tester.actor) end - # deprecated - def test_celebrity - assert_match(/\w+/, @tester.celebrity) - end - def test_quote assert_match(/\w+/, @tester.quote) end