From 382e49bb72245cdc2f6911c40c1d9c2139bf67e3 Mon Sep 17 00:00:00 2001 From: Keshav Biswa Date: Wed, 13 Dec 2023 14:21:13 +0530 Subject: [PATCH 01/18] update Faker::Australia to Faker::Locations::Australia --- lib/faker/locations/australia.rb | 78 ++++++++++--------- .../test_faker_australia.rb | 2 +- 2 files changed, 41 insertions(+), 39 deletions(-) rename test/faker/{location => locations}/test_faker_australia.rb (88%) diff --git a/lib/faker/locations/australia.rb b/lib/faker/locations/australia.rb index c0aeadf597..17016efd96 100644 --- a/lib/faker/locations/australia.rb +++ b/lib/faker/locations/australia.rb @@ -1,46 +1,48 @@ # frozen_string_literal: true module Faker - class Australia < Base - class << self - ## - # Produces a location in Australia - # - # @return [String] - # - # @example - # Faker::Australia.location - # #=> "Sydney" - # - # @faker.version next - def location - fetch('australia.locations') - end + class Locations + class Australia < Base + class << self + ## + # Produces a location in Australia + # + # @return [String] + # + # @example + # Faker::Locations::Australia.location + # #=> "Sydney" + # + # @faker.version next + def location + fetch('australia.locations') + end - # Produces an Australian animal - # - # @return [String] - # - # @example - # Faker::Australia.animal - # #=> "Dingo" - # - # @faker.version next - def animal - fetch('australia.animals') - end + # Produces an Australian animal + # + # @return [String] + # + # @example + # Faker::Locations::Australia.animal + # #=> "Dingo" + # + # @faker.version next + def animal + fetch('australia.animals') + end - # Produces an Australian State or Territory - # - # @return [String] - # - # @example - # Faker::Australia.state - # #=> "New South Wales" - # - # @faker.version next - def state - fetch('australia.states') + # Produces an Australian State or Territory + # + # @return [String] + # + # @example + # Faker::Locations::Australia.state + # #=> "New South Wales" + # + # @faker.version next + def state + fetch('australia.states') + end end end end diff --git a/test/faker/location/test_faker_australia.rb b/test/faker/locations/test_faker_australia.rb similarity index 88% rename from test/faker/location/test_faker_australia.rb rename to test/faker/locations/test_faker_australia.rb index 795da19ad6..e8a5b8fed3 100644 --- a/test/faker/location/test_faker_australia.rb +++ b/test/faker/locations/test_faker_australia.rb @@ -4,7 +4,7 @@ class TestFakerAustralia < Test::Unit::TestCase def setup - @tester = Faker::Australia + @tester = Faker::Locations::Australia end def test_location From d095a7c02302d2f591655ac395d5311a13b2e4bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 08:41:00 -0700 Subject: [PATCH 02/18] Bump minitest from 5.21.1 to 5.21.2 (#2894) Bumps [minitest](https://github.com/minitest/minitest) from 5.21.1 to 5.21.2. - [Changelog](https://github.com/minitest/minitest/blob/master/History.rdoc) - [Commits](https://github.com/minitest/minitest/compare/v5.21.1...v5.21.2) --- updated-dependencies: - dependency-name: minitest dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 6cc02f0e03..c93a5f2ec9 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ source 'https://rubygems.org' gemspec gem 'benchmark' -gem 'minitest', '5.21.1' +gem 'minitest', '5.21.2' gem 'pry', '0.14.2' gem 'rake', '13.1.0' gem 'rubocop', '1.59.0' diff --git a/Gemfile.lock b/Gemfile.lock index 2ca3a01942..2074dd69ab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,7 +17,7 @@ GEM json (2.7.1) language_server-protocol (3.17.0.3) method_source (1.0.0) - minitest (5.21.1) + minitest (5.21.2) parallel (1.24.0) parser (3.3.0.3) ast (~> 2.4.1) @@ -64,11 +64,12 @@ GEM PLATFORMS arm64-darwin-22 + x86_64-linux DEPENDENCIES benchmark faker! - minitest (= 5.21.1) + minitest (= 5.21.2) pry (= 0.14.2) rake (= 13.1.0) rubocop (= 1.59.0) From 18f4d3dc05fc3ebfde39fc45bf54d32b27a6fb66 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 08:44:56 -0700 Subject: [PATCH 03/18] Bump rubocop from 1.59.0 to 1.60.2 (#2896) Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.59.0 to 1.60.2. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.59.0...v1.60.2) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index c93a5f2ec9..4ae137e75a 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem 'benchmark' gem 'minitest', '5.21.2' gem 'pry', '0.14.2' gem 'rake', '13.1.0' -gem 'rubocop', '1.59.0' +gem 'rubocop', '1.60.2' gem 'rubocop-minitest', '0.34.4' gem 'rubocop-rake', '0.6.0' gem 'simplecov', '0.22.0' diff --git a/Gemfile.lock b/Gemfile.lock index 2074dd69ab..715ca8b2fa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,7 +19,7 @@ GEM method_source (1.0.0) minitest (5.21.2) parallel (1.24.0) - parser (3.3.0.3) + parser (3.3.0.5) ast (~> 2.4.1) racc power_assert (2.0.3) @@ -31,11 +31,11 @@ GEM rake (13.1.0) regexp_parser (2.9.0) rexml (3.2.6) - rubocop (1.59.0) + rubocop (1.60.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.4) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) @@ -72,7 +72,7 @@ DEPENDENCIES minitest (= 5.21.2) pry (= 0.14.2) rake (= 13.1.0) - rubocop (= 1.59.0) + rubocop (= 1.60.2) rubocop-minitest (= 0.34.4) rubocop-rake (= 0.6.0) simplecov (= 0.22.0) From 9e004ca9fe144b6cb76a208575acc918d693f17f Mon Sep 17 00:00:00 2001 From: Andrew Nduati Date: Mon, 5 Feb 2024 21:22:29 +0300 Subject: [PATCH 04/18] Add Kenya to supported countries (#2871) * Add Kenya to supported countries * Add tests for locale * clan up pull request * Add landline telephone numbers and cell phone formats --- lib/locales/en-KE.yml | 212 ++++++++++++++++++++++++++++++++++++++ test/test_en_ke_locale.rb | 42 ++++++++ 2 files changed, 254 insertions(+) create mode 100644 lib/locales/en-KE.yml create mode 100644 test/test_en_ke_locale.rb diff --git a/lib/locales/en-KE.yml b/lib/locales/en-KE.yml new file mode 100644 index 0000000000..d7e3e572d0 --- /dev/null +++ b/lib/locales/en-KE.yml @@ -0,0 +1,212 @@ +en-KE: + faker: + internet: + domain_suffix: + - ke + - co.ke + - org.ke + - or.ke + - go.ke + - ac.ke + - info.ke + address: + default_country: + - Republic of Kenya + default_country_code: + - KE + counties: + - Kiambu + - Siaya + - Bungoma + - Kericho + - Kilifi + - Kisumu + - Machakos + - Nakuru + - Kisii + - Busia + - Homa Bay + - Kajiado + - Kakamega + - Laikipia + - Migori + - Taita-Taveta + - Embu + - Kitui + - Meru + - Murang'a + - Nyamira + - Turkana + - Trans-Nzoia + - Uasin Gishu + - Vihiga + - Baringo + - Bomet + - Elgeyo-Marakwet + - Garissa + - Isiolo + - Kirinyaga + - Kwale + - Mandera + - Marsabit + - Mombasa + - Nairobi + - Nandi + - Narok + - Nyandarua + - Nyeri + - Samburu + - Tharaka-Nithi + - Wajir + - West Pokot + county: + - "#{counties}" + cities: + - Bungoma + - Busia + - El Wak + - Eldoret + - Emali + - Embu + - Gilgil + - Homa Bay + - Isiolo + - Juja + - Kakamega + - Karuri + - Kenol + - Kericho + - Kiambu + - Kikuyu + - Kilifi + - Kimilili + - Kiserian + - Kisii + - Kisumu + - Kitengela + - Limuru + - Lodwar + - Machakos + - Malindi + - Mandera + - Mavoko + - Meru + - Migori + - Mombasa + - Moyale + - Mtwapa + - Muranga + - Nairobi + - Naivasha + - Nakuru + - Nanyuki + - Narok + - Ngong + - Nyeri + - Ruiru + - Thika + - Ukunda + - Voi + - Wajir + - Wanguru + - Webuye + city: + - "#{cities}" + company: + company_names: + - ABSA Kenya + - ARM Cement + - Africa Development Bank (AfDB) + - B.O.C Kenya + - Bamburi Cement + - Britam Holdings + - British American Tobacco Kenya + - CIC Insurance Group + - Car & General (K) + - Carbacid Investments + - Centum Investment + - Crown Paints Kenya + - Deacons (East Africa) + - Diamond Trust Bank Kenya + - E.A Cables + - E.A Portland Cement + - Eaagads + - East African Breweries + - Equity Group Holdings + - Eveready East Africa + - Express Kenya + - Flame Tree Group Holdings + - HF Group + - Home Afrika + - Homeboyz Entertainment + - I & M Holdings + - ILAM Fahari I-REIT + - Jubilee Holdings + - KCB Group + - Kakuzi + - Kapchorua Tea Kenya + - KenGen + - Kenya Airways + - Kenya Orchards + - Kenya Power & Lighting + - Kenya Re-Insurance Corporation + - Kurwitu Ventures + - Liberty Kenya Holdings + - Limuru Tea + - Longhorn Publishers + - Mumias Sugar + - NCBA Group + - Nairobi Business Ventures + - Nairobi Securities Exchange + - Nation Media Group + - Olympia Capital Holdings + - Safaricom + - Sameer Africa + - Sanlam Kenya + - Sasini + - Stanbic Holdings + - Standard Chartered Bank Kenya + - Standard Group + - TPS Eastern Africa (Serena) + - The Co-operative Bank of Kenya + - Total Kenya + - Trans-Century + - Uchumi Supermarket + - Umeme + - Unga Group + - WPP Scangroup + - Williamson Tea Kenya + suffix: + - Co. + - Ltd + - Plc + - Trust + name: + - "#{company_names}" + phone_number: + country_code: + - "254" + area_code: + # area codes for Nairobi, Mombasa, Eldoret & Kisumu cities + - "20" + - "41" + - "51" + - "57" + formats: + - "### #######" + - "##########" + - "###-#######" + cell_phone: + formats: + # safaricom + - "0711 ######" + - "0722 ######" + # Airtel + - "010# ######" + - "0730 ######" + # Telkom + - "0770 ######" + - "0771 ######" + # Equitel + - "0763 ######" + - "0764 ######" \ No newline at end of file diff --git a/test/test_en_ke_locale.rb b/test/test_en_ke_locale.rb new file mode 100644 index 0000000000..ce088e8d0a --- /dev/null +++ b/test/test_en_ke_locale.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require_relative 'test_helper' + +class TestEnKeLocale < Test::Unit::TestCase + def setup + Faker::Config.locale = 'en-KE' + end + + def teardown + Faker::Config.locale = nil + end + + def test_en_ke_address_methods + assert Faker::Address.city.is_a? String + assert Faker::Address.county.is_a? String + assert Faker::Address.default_country.is_a? String + assert Faker::Address.default_country_code.is_a? String + end + + def test_en_ke_company_methods + assert Faker::Company.name.is_a? String + assert Faker::Company.suffix.is_a? String + assert Faker::Company.company_names.is_a? String + end + + def test_en_ke_internet_methods + assert Faker::Internet.domain_suffix.is_a? String + end + + def test_en_ke_country_code_starts_with_254 + phone_number = Faker::PhoneNumber.country_code + + assert_equal '+254', phone_number[0..3] + end + + def test_en_ke_cell_phone_starts_with_0 + cell_number = Faker::PhoneNumber.cell_phone + + assert_equal '0', cell_number[0] + end +end From d0aef262a6ef6861bb11ac69e9ed4ce81de4782b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 17:01:32 -0700 Subject: [PATCH 05/18] Bump minitest from 5.21.2 to 5.22.2 (#2902) Bumps [minitest](https://github.com/minitest/minitest) from 5.21.2 to 5.22.2. - [Changelog](https://github.com/minitest/minitest/blob/master/History.rdoc) - [Commits](https://github.com/minitest/minitest/compare/v5.21.2...v5.22.2) --- updated-dependencies: - dependency-name: minitest dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 4ae137e75a..6a4808d1f6 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ source 'https://rubygems.org' gemspec gem 'benchmark' -gem 'minitest', '5.21.2' +gem 'minitest', '5.22.2' gem 'pry', '0.14.2' gem 'rake', '13.1.0' gem 'rubocop', '1.60.2' diff --git a/Gemfile.lock b/Gemfile.lock index 715ca8b2fa..46daf42c23 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,7 +17,7 @@ GEM json (2.7.1) language_server-protocol (3.17.0.3) method_source (1.0.0) - minitest (5.21.2) + minitest (5.22.2) parallel (1.24.0) parser (3.3.0.5) ast (~> 2.4.1) @@ -69,7 +69,7 @@ PLATFORMS DEPENDENCIES benchmark faker! - minitest (= 5.21.2) + minitest (= 5.22.2) pry (= 0.14.2) rake (= 13.1.0) rubocop (= 1.60.2) From d62b619c95481df422660bb3c4e1c75f83e40df7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 17:01:58 -0700 Subject: [PATCH 06/18] Bump test-unit from 3.6.1 to 3.6.2 (#2906) Bumps [test-unit](https://github.com/test-unit/test-unit) from 3.6.1 to 3.6.2. - [Release notes](https://github.com/test-unit/test-unit/releases) - [Commits](https://github.com/test-unit/test-unit/compare/3.6.1...3.6.2) --- updated-dependencies: - dependency-name: test-unit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 6a4808d1f6..83c77b35ca 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,6 @@ gem 'rubocop', '1.60.2' gem 'rubocop-minitest', '0.34.4' gem 'rubocop-rake', '0.6.0' gem 'simplecov', '0.22.0' -gem 'test-unit', '3.6.1' +gem 'test-unit', '3.6.2' gem 'timecop', '0.9.8' gem 'yard', '0.9.34' diff --git a/Gemfile.lock b/Gemfile.lock index 46daf42c23..d85df7c7a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -56,7 +56,7 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - test-unit (3.6.1) + test-unit (3.6.2) power_assert timecop (0.9.8) unicode-display_width (2.5.0) @@ -76,7 +76,7 @@ DEPENDENCIES rubocop-minitest (= 0.34.4) rubocop-rake (= 0.6.0) simplecov (= 0.22.0) - test-unit (= 3.6.1) + test-unit (= 3.6.2) timecop (= 0.9.8) yard (= 0.9.34) From dea4fd76d9aaad11dac7761a6a8bd5868e552572 Mon Sep 17 00:00:00 2001 From: Jamal-A-Mohamed <37128483+Jamal-A-Mohamed@users.noreply.github.com> Date: Sun, 25 Feb 2024 15:01:38 -0600 Subject: [PATCH 07/18] Refactor `Faker::IDNumber` to `Faker::IdNumber` to be more consistent with other generator's naming convention. (#2858) * Deprecate IDNumber to IdNumber per issue#2787 * wip * Add a Faker::Deprecator module Co-authored-by: Thiago Araujo * Add more specs and improve warning message --------- Co-authored-by: jamal.mohamed Co-authored-by: Stefanni Brasil Co-authored-by: Thiago Araujo --- README.md | 2 +- doc/default/id_number.md | 40 +-- lib/faker/default/id_number.rb | 43 +-- lib/faker/default/south_africa.rb | 6 +- lib/helpers/deprecator.rb | 30 ++ lib/locales/en-US.yml | 2 +- lib/locales/en/id_number.yml | 2 +- test/faker/default/test_faker_id_number.rb | 329 ++++++++++++++++-- test/faker/default/test_faker_south_africa.rb | 6 +- test/test_determinism.rb | 44 ++- test/test_en_locale.rb | 8 +- test/test_en_us_locale.rb | 8 +- test/test_faker_deprecator.rb | 23 ++ 13 files changed, 464 insertions(+), 79 deletions(-) create mode 100644 lib/helpers/deprecator.rb create mode 100644 test/test_faker_deprecator.rb diff --git a/README.md b/README.md index a67d12d7cf..fa1f055491 100644 --- a/README.md +++ b/README.md @@ -248,7 +248,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main - [Faker::Hipster](doc/default/hipster.md) - [Faker::Hobby](doc/default/hobby.md) - [Faker::House](doc/default/house.md) - - [Faker::IDNumber](doc/default/id_number.md) + - [Faker::IdNumber](doc/default/id_number.md) - [Faker::IndustrySegments](doc/default/industry_segments.md) - [Faker::Internet](doc/default/internet.md) - [Faker::Invoice](doc/default/invoice.md) diff --git a/doc/default/id_number.md b/doc/default/id_number.md index e5fa858663..89216c0279 100644 --- a/doc/default/id_number.md +++ b/doc/default/id_number.md @@ -1,52 +1,52 @@ -# Faker::IDNumber +# Faker::IdNumber ```ruby # Generate a valid US Social Security number -Faker::IDNumber.valid #=> "552-56-3593" +Faker::IdNumber.valid #=> "552-56-3593" # Generate an invalid US Social Security number -Faker::IDNumber.invalid #=> "311-72-0000" +Faker::IdNumber.invalid #=> "311-72-0000" # Generate a Spanish citizen identifier (DNI) -Faker::IDNumber.spanish_citizen_number #=> "53290236-H" +Faker::IdNumber.spanish_citizen_number #=> "53290236-H" # Generate a Spanish foreign born citizen identifier (NIE) -Faker::IDNumber.spanish_foreign_citizen_number #=> "Z-1600870-Y" +Faker::IdNumber.spanish_foreign_citizen_number #=> "Z-1600870-Y" # Generate a valid South African ID Number -Faker::IDNumber.south_african_id_number #=> "8105128870184" +Faker::IdNumber.south_african_id_number #=> "8105128870184" # or -Faker::IDNumber.valid_south_african_id_number #=> "8105128870184" +Faker::IdNumber.valid_south_african_id_number #=> "8105128870184" # Generate an invalid South African ID Number -Faker::IDNumber.invalid_south_african_id_number #=> "1642972065088" +Faker::IdNumber.invalid_south_african_id_number #=> "1642972065088" # Generate a Brazilian citizen number (CPF) # Keyword arguments: formatted -Faker::IDNumber.brazilian_citizen_number #=> "53540542221" -Faker::IDNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21" +Faker::IdNumber.brazilian_citizen_number #=> "53540542221" +Faker::IdNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21" # Generate a Brazilian ID Number (RG) # Keyword arguments: formatted -Faker::IDNumber.brazilian_id #=> "493054029" -Faker::IDNumber.brazilian_id(formatted: true) #=> "49.305.402-9" +Faker::IdNumber.brazilian_id #=> "493054029" +Faker::IdNumber.brazilian_id(formatted: true) #=> "49.305.402-9" # Generate a Chilean ID (Rut with 8 digits) # For more advanced cases, please refer to Faker::ChileRut -Faker::IDNumber.chilean_id #=> "15620613-K" +Faker::IdNumber.chilean_id #=> "15620613-K" # Generate a Croatian ID number (OIB) # Keyword arguments: international -Faker::IDNumber.croatian_id #=> "88467617508" -Faker::IDNumber.croatian_id(international: true) #=> "HR88467617508" +Faker::IdNumber.croatian_id #=> "88467617508" +Faker::IdNumber.croatian_id(international: true) #=> "HR88467617508" # Generate a Danish ID number (CPR) # Keyword arguments: formatted, gender, birthday -Faker::IDNumber.danish_id_number #=> "050390-9980" -Faker::IDNumber.danish_id_number(formatted: true) #=> "050390-9980" -Faker::IDNumber.danish_id_number(birthday: Date.new(1990, 3, 5)) #=> "050390-9980" -Faker::IDNumber.danish_id_number(gender: :female) #=> "050390-9980" +Faker::IdNumber.danish_id_number #=> "050390-9980" +Faker::IdNumber.danish_id_number(formatted: true) #=> "050390-9980" +Faker::IdNumber.danish_id_number(birthday: Date.new(1990, 3, 5)) #=> "050390-9980" +Faker::IdNumber.danish_id_number(gender: :female) #=> "050390-9980" # Generate a valid French Social Security number (INSEE number) -Faker::IDNumber.french_insee_number #=> "22510589696868" +Faker::IdNumber.french_insee_number #=> "22510589696868" ``` diff --git a/lib/faker/default/id_number.rb b/lib/faker/default/id_number.rb index 5e08dfbeb9..b02c17b77e 100644 --- a/lib/faker/default/id_number.rb +++ b/lib/faker/default/id_number.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Faker - class IDNumber < Base + class IdNumber < Base CHECKS = 'TRWAGMYFPDXBNJZSQVHLCKE' INVALID_SSN = [ /0{3}-\d{2}-\d{4}/, @@ -25,7 +25,7 @@ class << self # @return [String] # # @example - # Faker::IDNumber.valid #=> "552-56-3593" + # Faker::IdNumber.valid #=> "552-56-3593" # # @faker.version 1.6.0 def valid @@ -38,7 +38,7 @@ def valid # @return [String] # # @example - # Faker::IDNumber.invalid #=> "311-72-0000" + # Faker::IdNumber.invalid #=> "311-72-0000" # # @faker.version 1.6.0 def invalid @@ -71,7 +71,7 @@ def ssn_valid # @return [String] # # @example - # Faker::IDNumber.spanish_citizen_number #=> "53290236-H" + # Faker::IdNumber.spanish_citizen_number #=> "53290236-H" # # @faker.version 1.9.0 def spanish_citizen_number @@ -87,7 +87,7 @@ def spanish_citizen_number # @return [String] # # @example - # Faker::IDNumber.spanish_foreign_citizen_number #=> "Z-1600870-Y" + # Faker::IdNumber.spanish_foreign_citizen_number #=> "Z-1600870-Y" # # @faker.version 1.9.0 def spanish_foreign_citizen_number @@ -106,8 +106,8 @@ def spanish_foreign_citizen_number # @return [String] # # @example - # Faker::IDNumber.south_african_id_number #=> "8105128870184" - # Faker::IDNumber.valid_south_african_id_number #=> "8105128870184" + # Faker::IdNumber.south_african_id_number #=> "8105128870184" + # Faker::IdNumber.valid_south_african_id_number #=> "8105128870184" # # @faker.version 1.9.2 def valid_south_african_id_number @@ -129,7 +129,7 @@ def valid_south_african_id_number # @return [String] # # @example - # Faker::IDNumber.invalid_south_african_id_number #=> "1642972065088" + # Faker::IdNumber.invalid_south_african_id_number #=> "1642972065088" # # @faker.version 1.9.2 def invalid_south_african_id_number @@ -156,8 +156,8 @@ def invalid_south_african_id_number # @return [String] # # @example - # Faker::IDNumber.brazilian_citizen_number #=> "53540542221" - # Faker::IDNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21" + # Faker::IdNumber.brazilian_citizen_number #=> "53540542221" + # Faker::IdNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21" # # @faker.version 1.9.2 def brazilian_citizen_number(formatted: false) @@ -177,8 +177,8 @@ def brazilian_citizen_number(formatted: false) # @return [String] # # @example - # Faker::IDNumber.brazilian_id #=> "493054029" - # Faker::IDNumber.brazilian_id(formatted: true) #=> "49.305.402-9" + # Faker::IdNumber.brazilian_id #=> "493054029" + # Faker::IdNumber.brazilian_id(formatted: true) #=> "49.305.402-9" # # @faker.version 2.1.2 def brazilian_id(formatted: false) @@ -196,7 +196,7 @@ def brazilian_id(formatted: false) # @return [String] # # @example - # Faker::IDNumber.chilean_id #=> "15620613-K" + # Faker::IdNumber.chilean_id #=> "15620613-K" # # @faker.version 2.1.2 def chilean_id @@ -213,8 +213,8 @@ def chilean_id # @return [String] # # @example - # Faker::IDNumber.croatian_id #=> "88467617508" - # Faker::IDNumber.croatian_id(international: true) #=> "HR88467617508" + # Faker::IdNumber.croatian_id #=> "88467617508" + # Faker::IdNumber.croatian_id(international: true) #=> "HR88467617508" # # @faker.version next def croatian_id(international: false) @@ -238,10 +238,10 @@ def croatian_id(international: false) # @return [String] # # @example - # Faker::IDNumber.danish_id_number #=> "0503909980" - # Faker::IDNumber.danish_id_number(formatted: true) #=> "050390-9980" - # Faker::IDNumber.danish_id_number(birthday: Date.new(1990, 3, 5)) #=> "0503909980" - # Faker::IDNumber.danish_id_number(gender: :female) #=> "0503909980" + # Faker::IdNumber.danish_id_number #=> "0503909980" + # Faker::IdNumber.danish_id_number(formatted: true) #=> "050390-9980" + # Faker::IdNumber.danish_id_number(birthday: Date.new(1990, 3, 5)) #=> "0503909980" + # Faker::IdNumber.danish_id_number(gender: :female) #=> "0503909980" # # @faker.version next def danish_id_number(formatted: false, birthday: Faker::Date.birthday, gender: nil) @@ -275,7 +275,7 @@ def danish_id_number(formatted: false, birthday: Faker::Date.birthday, gender: n # @return [String] # # @example - # Faker::IDNumber.french_insee_number #=> "53290236-H" + # Faker::IdNumber.french_insee_number #=> "53290236-H" # # @faker.version next def french_insee_number @@ -421,4 +421,7 @@ def _translate(key) end end end + + include Faker::Deprecator + deprecate_generator('IDNumber', IdNumber) end diff --git a/lib/faker/default/south_africa.rb b/lib/faker/default/south_africa.rb index 09fdbd8bd5..db8cb3e143 100644 --- a/lib/faker/default/south_africa.rb +++ b/lib/faker/default/south_africa.rb @@ -13,7 +13,7 @@ class << self # # @faker.version 1.9.2 def id_number - Faker::IDNumber.south_african_id_number + Faker::IdNumber.south_african_id_number end ## @@ -26,7 +26,7 @@ def id_number # # @faker.version 1.9.2 def valid_id_number - Faker::IDNumber.valid_south_african_id_number + Faker::IdNumber.valid_south_african_id_number end ## @@ -39,7 +39,7 @@ def valid_id_number # # @faker.version 1.9.2 def invalid_id_number - Faker::IDNumber.invalid_south_african_id_number + Faker::IdNumber.invalid_south_african_id_number end ## diff --git a/lib/helpers/deprecator.rb b/lib/helpers/deprecator.rb new file mode 100644 index 0000000000..e280cf9423 --- /dev/null +++ b/lib/helpers/deprecator.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +# Based on Rails ActiveSupport Deprecator +# https://github.com/rails/rails/blob/6f0d1ad14b92b9f5906e44740fce8b4f1c7075dc/activesupport/lib/active_support/deprecation/constant_accessor.rb + +# rubocop:disable Style/ClassVars +module Faker + module Deprecator + def self.included(base) + extension = Module.new do + def const_missing(missing_const_name) + if class_variable_defined?(:@@_deprecated_constants) && (replacement = class_variable_get(:@@_deprecated_constants)[missing_const_name.to_s]) + $stdout.puts("DEPRECATION WARNING: #{name}::#{replacement[:old_generator]} is deprecated. Use #{replacement[:new_constant]} instead.") + return replacement[:new_constant] + end + + super + end + + def deprecate_generator(old_generator_name, new_generator_constant) + class_variable_set(:@@_deprecated_constants, {}) unless class_variable_defined?(:@@_deprecated_constants) + class_variable_get(:@@_deprecated_constants)[old_generator_name] = { new_constant: new_generator_constant, old_generator: old_generator_name } + end + end + + base.singleton_class.prepend extension + end + end +end +# rubocop:enable Style/ClassVars diff --git a/lib/locales/en-US.yml b/lib/locales/en-US.yml index a447eb5fef..2fed35282c 100644 --- a/lib/locales/en-US.yml +++ b/lib/locales/en-US.yml @@ -6960,7 +6960,7 @@ en-US: - "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}" - "#{PhoneNumber.area_code}.#{PhoneNumber.exchange_code}.#{PhoneNumber.subscriber_number}" id_number: - valid: "#{IDNumber.ssn_valid}" + valid: "#{IdNumber.ssn_valid}" invalid: - 000-##-#### - "###-00-####" diff --git a/lib/locales/en/id_number.yml b/lib/locales/en/id_number.yml index ac1df752ce..597eab1690 100644 --- a/lib/locales/en/id_number.yml +++ b/lib/locales/en/id_number.yml @@ -1,5 +1,5 @@ en: faker: id_number: - valid: "#{IDNumber.ssn_valid}" + valid: "#{IdNumber.ssn_valid}" invalid: ['000-##-####', '###-00-####', '###-##-0000', '666-##-####', '9##-##-####'] diff --git a/test/faker/default/test_faker_id_number.rb b/test/faker/default/test_faker_id_number.rb index 21a2389ea9..3e66178367 100644 --- a/test/faker/default/test_faker_id_number.rb +++ b/test/faker/default/test_faker_id_number.rb @@ -3,6 +3,293 @@ require_relative '../../test_helper' class TestFakerIdNumber < Test::Unit::TestCase + def setup + @tester = Faker::IdNumber + 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 + +class TestFakerIDNumber < Test::Unit::TestCase def setup @tester = Faker::IDNumber end @@ -37,7 +324,7 @@ def test_spanish_dni assert_equal('-', sample[8]) mod = sample[0..7].to_i % 23 - assert_equal Faker::IDNumber::CHECKS[mod], sample[9] + assert_equal Faker::IdNumber::CHECKS[mod], sample[9] end def test_spanish_nie @@ -51,7 +338,7 @@ def test_spanish_nie prefix = 'XYZ'.index(sample[0]).to_s mod = "#{prefix}#{sample[2..8]}".to_i % 23 - assert_equal Faker::IDNumber::CHECKS[mod], sample[10] + assert_equal Faker::IdNumber::CHECKS[mod], sample[10] end def test_south_african_id_number @@ -98,35 +385,35 @@ def test_brazilian_id_formatted def test_brazilian_citizen_number_checksum_digit digits = '128991760' - checksum_digit = Faker::IDNumber.send(:brazilian_citizen_number_checksum_digit, digits) + 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) + 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) + 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) + 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) + 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) @@ -136,17 +423,17 @@ def test_brazilian_document_digit 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) + 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) + 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) @@ -160,13 +447,13 @@ def test_chilean_id end def test_chilean_verification_code_k - verification_code = Faker::IDNumber.send(:chilean_verification_code, 20_680_873) + 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) + verification_code = Faker::IdNumber.send(:chilean_verification_code, 13_196_022) assert_equal(0, verification_code) end @@ -185,7 +472,7 @@ def test_croatian_id_international def test_croatian_id_checksum_digit digits = '8764670153' - checksum_digit = Faker::IDNumber.send(:croatian_id_checksum_digit, digits) + checksum_digit = Faker::IdNumber.send(:croatian_id_checksum_digit, digits) assert_equal(5, checksum_digit) end @@ -283,8 +570,8 @@ def south_african_id_number_to_date_of_birth_string(sample) 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_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_south_africa.rb b/test/faker/default/test_faker_south_africa.rb index 8e7e53e215..608121fbf2 100644 --- a/test/faker/default/test_faker_south_africa.rb +++ b/test/faker/default/test_faker_south_africa.rb @@ -10,7 +10,7 @@ def setup def test_id_number stubbed_id_number = '7201010001081' - Faker::IDNumber.stub :south_african_id_number, stubbed_id_number do + Faker::IdNumber.stub :south_african_id_number, stubbed_id_number do assert_equal stubbed_id_number, @tester.id_number end end @@ -18,7 +18,7 @@ def test_id_number def test_valid_id_number stubbed_id_number = '7201010001081' - Faker::IDNumber.stub :valid_south_african_id_number, stubbed_id_number do + Faker::IdNumber.stub :valid_south_african_id_number, stubbed_id_number do assert_equal stubbed_id_number, @tester.valid_id_number end end @@ -26,7 +26,7 @@ def test_valid_id_number def test_invalid_id_number stubbed_id_number = '9999990001081' - Faker::IDNumber.stub :invalid_south_african_id_number, stubbed_id_number do + Faker::IdNumber.stub :invalid_south_african_id_number, stubbed_id_number do assert_equal stubbed_id_number, @tester.invalid_id_number end end diff --git a/test/test_determinism.rb b/test/test_determinism.rb index 807852a0bd..69ddf28979 100644 --- a/test/test_determinism.rb +++ b/test/test_determinism.rb @@ -67,7 +67,7 @@ def all_methods def subclasses Faker.constants.delete_if do |subclass| - %i[Base Bank Books Cat Char Base58 ChileRut CLI Config Creature Date Dog DragonBall Dota ElderScrolls Fallout Games GamesHalfLife HeroesOfTheStorm Internet JapaneseMedia LeagueOfLegends Movies Myst Overwatch OnePiece Pokemon Religion Sports SwordArtOnline TvShows Time VERSION Witcher WorldOfWarcraft Zelda].include?(subclass) + skipped_classes.include?(subclass) end.sort end @@ -76,5 +76,47 @@ def subclass_methods(subclass) "Faker::#{subclass}.#{method}" end.sort end + + def skipped_classes + %i[ + Bank + Base + Base58 + Books + Cat + Char + ChileRut + CLI + Config + Creature + Date + Deprecator + Dog + DragonBall + Dota + ElderScrolls + Fallout + Games + GamesHalfLife + HeroesOfTheStorm + Internet + JapaneseMedia + LeagueOfLegends + Movies + Myst + Overwatch + OnePiece + Pokemon + Religion + Sports + SwordArtOnline + TvShows + Time + VERSION + Witcher + WorldOfWarcraft + Zelda + ] + end end # rubocop:enable Security/Eval,Style/EvalWithLocation diff --git a/test/test_en_locale.rb b/test/test_en_locale.rb index 3e530aa1bd..d6dec7eed5 100644 --- a/test/test_en_locale.rb +++ b/test/test_en_locale.rb @@ -23,15 +23,15 @@ def test_us_zip_codes end def test_valid_id_number - id_num = Faker::IDNumber.valid + id_num = Faker::IdNumber.valid - assert(Faker::IDNumber::INVALID_SSN.none? { |regex| id_num =~ regex }) + assert(Faker::IdNumber::INVALID_SSN.none? { |regex| id_num =~ regex }) end def test_invalid_id_number - id_num = Faker::IDNumber.invalid + id_num = Faker::IdNumber.invalid - assert(Faker::IDNumber::INVALID_SSN.any? { |regex| id_num =~ regex }) + assert(Faker::IdNumber::INVALID_SSN.any? { |regex| id_num =~ regex }) end def test_values_trimmed diff --git a/test/test_en_us_locale.rb b/test/test_en_us_locale.rb index c7c6a85362..f33a487e2d 100644 --- a/test/test_en_us_locale.rb +++ b/test/test_en_us_locale.rb @@ -85,14 +85,14 @@ def test_en_us_zip_codes_match_state end def test_en_us_valid_id_number - id_num = Faker::IDNumber.valid + id_num = Faker::IdNumber.valid - assert(Faker::IDNumber::INVALID_SSN.none? { |regex| id_num =~ regex }) + assert(Faker::IdNumber::INVALID_SSN.none? { |regex| id_num =~ regex }) end def test_en_us_invalid_id_number - id_num = Faker::IDNumber.invalid + id_num = Faker::IdNumber.invalid - assert(Faker::IDNumber::INVALID_SSN.any? { |regex| id_num =~ regex }) + assert(Faker::IdNumber::INVALID_SSN.any? { |regex| id_num =~ regex }) end end diff --git a/test/test_faker_deprecator.rb b/test/test_faker_deprecator.rb new file mode 100644 index 0000000000..0083a2203c --- /dev/null +++ b/test/test_faker_deprecator.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require_relative 'test_helper' + +class TestFakerDeprecation < Test::Unit::TestCase + def test_using_a_deprecated_generator_returns_a_warning_message + actual_stdout, actual_stderr = capture_output do + Faker::IDNumber.valid + end + + assert_includes(actual_stdout, 'DEPRECATION WARNING: Faker::IDNumber is deprecated. Use Faker::IdNumber instead') + assert_empty(actual_stderr) + end + + def test_using_a_non_deprecated_generator_does_not_return_a_warning_message + actual_stdout, actual_stderr = capture_output do + Faker::IdNumber.valid + end + + assert_empty(actual_stdout) + assert_empty(actual_stderr) + end +end From 964a223a9c9c165dc471118a4fc515cb3b38edb5 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Mon, 26 Feb 2024 10:09:59 -0800 Subject: [PATCH 08/18] Fix/Deprecate FmaBrotherhood Generator (#2856) * Favor 'The Room' instead of 'Room' This commit will rename instances of room to the_room including the locales. Originally the `room.md` had a typo that referenced ::Room and not ::TheRoom which is also fixed here. Ref: - https://github.com/faker-ruby/faker/issues/2787 Co-authored-by: Jamal-A-Mohamed Co-authored-by: Salvador * Fix/Deprecate FmaBrotherhood Generator This commit fixes the naming discrpencies with the FmaBrotherhood (now FullmetalAlchemistBrotherhood) class and its filename. This adds deprecation warnings for the old FmaBrotherhood class and also makes the new FullmetalAlchemistBrotherhood class. Fix: - https://github.com/faker-ruby/faker/issues/2853 * Refactor deprecation for `FmaBrotherhood` This commit will refactor the changes from `FmaBrotherhood` to `FullmetalAlchemistBrotherhood` and use `Faker::Deprecator`. --------- Co-authored-by: Jamal-A-Mohamed Co-authored-by: Salvador Co-authored-by: Stefanni Brasil --- README.md | 2 +- .../fullmetal_alchemist_brotherhood.md | 8 +++---- .../fullmetal_alchemist_brotherhood.rb | 23 +++++++++++-------- ...ml => fullmetal_alchemist_brotherhood.yml} | 6 ++--- ...t_faker_fullmetal_alchemist_brotherhood.rb | 18 +++++++++++++++ 5 files changed, 39 insertions(+), 18 deletions(-) rename lib/locales/en/{fma_brotherhood.yml => fullmetal_alchemist_brotherhood.yml} (95%) diff --git a/README.md b/README.md index fa1f055491..02aaa8ce02 100644 --- a/README.md +++ b/README.md @@ -376,7 +376,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main - [Faker::JapaneseMedia::Naruto](doc/japanese_media/naruto.md) - [Faker::JapaneseMedia::Doraemon](doc/japanese_media/doraemon.md) - [Faker::JapaneseMedia::Conan](doc/japanese_media/conan.md) - - [Faker::JapaneseMedia::FmaBrotherhood](doc/japanese_media/fullmetal_alchemist_brotherhood.md) + - [Faker::JapaneseMedia::FullmetalAlchemistBrotherhood](doc/japanese_media/fullmetal_alchemist_brotherhood.md)
diff --git a/doc/japanese_media/fullmetal_alchemist_brotherhood.md b/doc/japanese_media/fullmetal_alchemist_brotherhood.md index 12c2ffa880..ddd6f1074e 100644 --- a/doc/japanese_media/fullmetal_alchemist_brotherhood.md +++ b/doc/japanese_media/fullmetal_alchemist_brotherhood.md @@ -1,9 +1,9 @@ -# Faker::JapaneseMedia::FmaBrotherhood +# Faker::JapaneseMedia::FullmetalAchemistBrotherhood ```ruby -Faker::JapaneseMedia::FmaBrotherhood.character #=> "Edward Elric" +Faker::JapaneseMedia::FullmetalAchemistBrotherhood.character #=> "Edward Elric" -Faker::JapaneseMedia::FmaBrotherhood.city #=> "Central City" +Faker::JapaneseMedia::FullmetalAchemistBrotherhood.city #=> "Central City" -Faker::JapaneseMedia::FmaBrotherhood.country #=> "Xing" +Faker::JapaneseMedia::FullmetalAchemistBrotherhood.country #=> "Xing" ``` diff --git a/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb b/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb index b07ba37609..493cdf51a0 100644 --- a/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb +++ b/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb @@ -2,47 +2,50 @@ module Faker class JapaneseMedia - class FmaBrotherhood < Base + class FullmetalAlchemistBrotherhood < Base class << self ## - # Produces a character from FmaBrotherhood. + # Produces a character from FullmetalAlchemistBrotherhood. # # @return [String] # # @example - # Faker::JapaneseMedia::FmaBrotherhood.character #=> "Edward Elric" + # Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.character #=> "Edward Elric" # # @faker.version next def character - fetch('fma_brotherhood.characters') + fetch('fullmetal_alchemist_brotherhood.characters') end ## - # Produces a cities from FmaBrotherhood. + # Produces a cities from FullmetalAlchemistBrotherhood. # # @return [String] # # @example - # Faker::JapaneseMedia::FmaBrotherhood.city #=> "Central City" + # Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.city #=> "Central City" # # @faker.version next def city - fetch('fma_brotherhood.cities') + fetch('fullmetal_alchemist_brotherhood.cities') end ## - # Produces a country from FmaBrotherhood. + # Produces a country from FullmetalAlchemistBrotherhood. # # @return [String] # # @example - # Faker::JapaneseMedia::FmaBrotherhood.country #=> "Xing" + # Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.country #=> "Xing" # # @faker.version next def country - fetch('fma_brotherhood.countries') + fetch('fullmetal_alchemist_brotherhood.countries') end end end + + include Faker::Deprecator + deprecate_generator('FmaBrotherhood', FullmetalAlchemistBrotherhood) end end diff --git a/lib/locales/en/fma_brotherhood.yml b/lib/locales/en/fullmetal_alchemist_brotherhood.yml similarity index 95% rename from lib/locales/en/fma_brotherhood.yml rename to lib/locales/en/fullmetal_alchemist_brotherhood.yml index d83966071c..6061fe4093 100644 --- a/lib/locales/en/fma_brotherhood.yml +++ b/lib/locales/en/fullmetal_alchemist_brotherhood.yml @@ -1,6 +1,6 @@ en: faker: - fma_brotherhood: + fullmetal_alchemist_brotherhood: characters: - Edward Elric - Alphonse Elric @@ -8,7 +8,7 @@ en: - Riza Hawkeye - Scar - Winry Rockbell - - May Chang + - May Chang - Maes Hughes - Alex Louis Armstrong - Jean Havoc @@ -47,7 +47,7 @@ en: - Isaac McDougal - Solf J. Kimblee - Van Hohenheim - - Fu + - Fu - Ling Yao - Lan Fan - Olivier Mira Armstrong 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 ad23e96de1..f651796a6a 100644 --- a/test/faker/japanese_media/test_faker_fullmetal_alchemist_brotherhood.rb +++ b/test/faker/japanese_media/test_faker_fullmetal_alchemist_brotherhood.rb @@ -19,3 +19,21 @@ def test_country assert_match(/\w+/, @tester.country) end end + +class TestFakerFullmetalAlchemistBrotherhood < Test::Unit::TestCase + def setup + @tester = Faker::JapaneseMedia::FullmetalAlchemistBrotherhood + 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 From 08801ce216bdc9feb4c2ff3059ae713dbae1dc91 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:45:03 -0600 Subject: [PATCH 09/18] Bump i18n from 1.14.1 to 1.14.4 (#2913) Bumps [i18n](https://github.com/ruby-i18n/i18n) from 1.14.1 to 1.14.4. - [Release notes](https://github.com/ruby-i18n/i18n/releases) - [Changelog](https://github.com/ruby-i18n/i18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/ruby-i18n/i18n/compare/v1.14.1...v1.14.4) --- updated-dependencies: - dependency-name: i18n dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d85df7c7a0..aaf5461f2c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,9 +10,9 @@ GEM ast (2.4.2) benchmark (0.3.0) coderay (1.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) docile (1.4.0) - i18n (1.14.1) + i18n (1.14.4) concurrent-ruby (~> 1.0) json (2.7.1) language_server-protocol (3.17.0.3) From ebd93ab049f1f7b8d2b0cf3ae7f43385dad0cfc5 Mon Sep 17 00:00:00 2001 From: Michael Marusyk <31774981+mmarusyk@users.noreply.github.com> Date: Wed, 13 Mar 2024 04:45:12 +0200 Subject: [PATCH 10/18] Remove duplicates in doc file (#2914) --- doc/default/commerce.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/default/commerce.md b/doc/default/commerce.md index b8d751ab00..e1fd0531c7 100644 --- a/doc/default/commerce.md +++ b/doc/default/commerce.md @@ -22,8 +22,6 @@ Faker::Commerce.price(range: 0..10.0, as_string: true) #=> "2.18" Faker::Commerce.promotion_code #=> "AmazingDeal829102" Faker::Commerce.promotion_code(digits: 2) #=> "AmazingPrice57" -Faker::Commerce.material #=> "Plastic" - # Generate a random brand Faker::Commerce.brand #=> "Apple" From b03b2cc14ee71aa4fda3a643578e7c14c200d16d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:47:02 -0600 Subject: [PATCH 11/18] Bump rubocop from 1.60.2 to 1.62.1 (#2916) Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.60.2 to 1.62.1. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.60.2...v1.62.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 83c77b35ca..8230f3bf96 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem 'benchmark' gem 'minitest', '5.22.2' gem 'pry', '0.14.2' gem 'rake', '13.1.0' -gem 'rubocop', '1.60.2' +gem 'rubocop', '1.62.1' gem 'rubocop-minitest', '0.34.4' gem 'rubocop-rake', '0.6.0' gem 'simplecov', '0.22.0' diff --git a/Gemfile.lock b/Gemfile.lock index aaf5461f2c..c2da23a2c4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,7 +31,7 @@ GEM rake (13.1.0) regexp_parser (2.9.0) rexml (3.2.6) - rubocop (1.60.2) + rubocop (1.62.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -39,11 +39,11 @@ GEM rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) + rubocop-ast (1.31.2) + parser (>= 3.3.0.4) rubocop-minitest (0.34.4) rubocop (>= 1.39, < 2.0) rubocop-ast (>= 1.30.0, < 2.0) @@ -72,7 +72,7 @@ DEPENDENCIES minitest (= 5.22.2) pry (= 0.14.2) rake (= 13.1.0) - rubocop (= 1.60.2) + rubocop (= 1.62.1) rubocop-minitest (= 0.34.4) rubocop-rake (= 0.6.0) simplecov (= 0.22.0) From 7f05e4885f90ca700a599da922d9a7f0d7efd480 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:56:59 -0600 Subject: [PATCH 12/18] Bump yard from 0.9.34 to 0.9.36 (#2909) Bumps [yard](https://github.com/lsegal/yard) from 0.9.34 to 0.9.36. - [Release notes](https://github.com/lsegal/yard/releases) - [Changelog](https://github.com/lsegal/yard/blob/main/CHANGELOG.md) - [Commits](https://github.com/lsegal/yard/compare/v0.9.34...v0.9.36) --- updated-dependencies: - dependency-name: yard dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 8230f3bf96..2fcfe61b91 100644 --- a/Gemfile +++ b/Gemfile @@ -15,4 +15,4 @@ gem 'rubocop-rake', '0.6.0' gem 'simplecov', '0.22.0' gem 'test-unit', '3.6.2' gem 'timecop', '0.9.8' -gem 'yard', '0.9.34' +gem 'yard', '0.9.36' diff --git a/Gemfile.lock b/Gemfile.lock index c2da23a2c4..7140563363 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,7 +60,7 @@ GEM power_assert timecop (0.9.8) unicode-display_width (2.5.0) - yard (0.9.34) + yard (0.9.36) PLATFORMS arm64-darwin-22 @@ -78,7 +78,7 @@ DEPENDENCIES simplecov (= 0.22.0) test-unit (= 3.6.2) timecop (= 0.9.8) - yard (= 0.9.34) + yard (= 0.9.36) BUNDLED WITH 2.2.33 From 8cb3f4f8130773339d7b1f6b912ccd548962e941 Mon Sep 17 00:00:00 2001 From: Keshav Biswa Date: Sun, 17 Mar 2024 17:31:34 +0530 Subject: [PATCH 13/18] Deprecated Faker::Australia --- lib/faker/locations/australia.rb | 3 +++ test/faker/locations/test_faker_australia.rb | 20 +++++++++++++++++++- test/test_determinism.rb | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/faker/locations/australia.rb b/lib/faker/locations/australia.rb index 17016efd96..e2a82027d6 100644 --- a/lib/faker/locations/australia.rb +++ b/lib/faker/locations/australia.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true module Faker + extend Deprecator + class Locations class Australia < Base class << self @@ -46,4 +48,5 @@ def state end end end + deprecate_generator('Australia', Locations::Australia) end diff --git a/test/faker/locations/test_faker_australia.rb b/test/faker/locations/test_faker_australia.rb index e8a5b8fed3..d4542ca8f0 100644 --- a/test/faker/locations/test_faker_australia.rb +++ b/test/faker/locations/test_faker_australia.rb @@ -2,7 +2,7 @@ require_relative '../../test_helper' -class TestFakerAustralia < Test::Unit::TestCase +class TestFakerLocationsAustralia < Test::Unit::TestCase def setup @tester = Faker::Locations::Australia end @@ -19,3 +19,21 @@ def test_state assert_match(/\w+/, @tester.state) end end + +class TestFakerAustralia < Test::Unit::TestCase + def setup + @tester = Faker::Australia + end + + def test_location + assert_match(/\w+/, @tester.location) + end + + def test_animal + assert_match(/\w+/, @tester.animal) + end + + def test_state + assert_match(/\w+/, @tester.state) + end +end diff --git a/test/test_determinism.rb b/test/test_determinism.rb index 69ddf28979..0dd805d125 100644 --- a/test/test_determinism.rb +++ b/test/test_determinism.rb @@ -102,6 +102,7 @@ def skipped_classes Internet JapaneseMedia LeagueOfLegends + Locations Movies Myst Overwatch From 783b8a9b29247814fe6567ffeb4e83a67654d5d4 Mon Sep 17 00:00:00 2001 From: Keshav Biswa Date: Mon, 18 Mar 2024 21:54:18 +0530 Subject: [PATCH 14/18] Added Docs for Australia --- doc/locations/australia.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 doc/locations/australia.md diff --git a/doc/locations/australia.md b/doc/locations/australia.md new file mode 100644 index 0000000000..efa06a13ea --- /dev/null +++ b/doc/locations/australia.md @@ -0,0 +1,9 @@ +# Faker::Locations::Australia + +```ruby +Faker::Locations::Australia.location # => "Sydney" + +Faker::Locations::Australia.animal # => "Kangaroo" + +Faker::Locations::Australia.state # => "New South Wales" +``` From 7df8a087b0d9008c512d6b741ff153e56ac2f2bc Mon Sep 17 00:00:00 2001 From: Keshav Biswa Date: Mon, 18 Mar 2024 21:58:26 +0530 Subject: [PATCH 15/18] Updated Readme to include Locations --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 02aaa8ce02..104c93f2e3 100644 --- a/README.md +++ b/README.md @@ -477,6 +477,12 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main - [Faker::TvShows::VentureBros](doc/tv_shows/venture_bros.md)
+
+ Locations + + - [Faker::Locations::Australia](doc/locations/australia.md) +
+ ## Contributing **Note**: We are not accepting proposals for new generators and locales. The [Contributing](CONTRIBUTING.md) guide has a few notes about this decision. From 9d69731087321c7f4d0f76c869cf7b38f7e8b9c8 Mon Sep 17 00:00:00 2001 From: Keshav Biswa Date: Tue, 19 Mar 2024 10:54:15 +0530 Subject: [PATCH 16/18] Updated locales path for australia --- lib/faker/locations/australia.rb | 6 +- lib/locales/en/australia.yml | 211 ++++++++++++++++--------------- 2 files changed, 109 insertions(+), 108 deletions(-) diff --git a/lib/faker/locations/australia.rb b/lib/faker/locations/australia.rb index e2a82027d6..56ae93c9d0 100644 --- a/lib/faker/locations/australia.rb +++ b/lib/faker/locations/australia.rb @@ -17,7 +17,7 @@ class << self # # @faker.version next def location - fetch('australia.locations') + fetch('locations.australia.locations') end # Produces an Australian animal @@ -30,7 +30,7 @@ def location # # @faker.version next def animal - fetch('australia.animals') + fetch('locations.australia.animals') end # Produces an Australian State or Territory @@ -43,7 +43,7 @@ def animal # # @faker.version next def state - fetch('australia.states') + fetch('locations.australia.states') end end end diff --git a/lib/locales/en/australia.yml b/lib/locales/en/australia.yml index 69864857c0..25df41ebc0 100644 --- a/lib/locales/en/australia.yml +++ b/lib/locales/en/australia.yml @@ -1,107 +1,108 @@ en: faker: - australia: - locations: - - Brisbane - - Sydney - - Melbourne - - Perth - - Adelaide - - Gold Coast - - Newcastle - - Canberra - - Central Coast - - Sunshine Coast - - Wollongong - - Geelong - - Hobart - - Townsville - - Cairns - - Toowoomba - - Darwin - - Ballarat - - Bendigo - - Albury - - Launceston - - Mackay - - Rockhampton - - Bunbury - - Coffs Harbour - - Bundaberg - - Melton - - Wagga Wagga - - Hervey Bay - - Mildura – Wentworth - - Shepparton – Mooroopna - - Port Macquarie - - Gladstone – Tannum Sands - - Tamworth - - Traralgon – Morwell - - Orange - - Bowral – Mittagong - - Busselton - - Geraldton - - Dubbo - - Nowra – Bomaderry - - Warragul – Drouin - - Bathurst - - Warrnambool - - Albany - - Kalgoorlie - - Devonport - - Mount Gambier - - Lismore - - Nelson Bay - animals: - - Koala - - Humpback Whale - - Australian Fur Seal - - Wallaby - - Platypus - - Kangaroo - - Wombat - - Sugar Glider - - Flying Fox - - Tasmanian Devil - - Quokka - - Dugong - - Luaner - - Echidna - - Magpie - - Cockatoo - - Tawny Frogmouth - - Galah - - Lorikeet - - Pelican - - Cassowary - - Kookaburra - - Emu - - Lyrebird - - Barramundi - - Grouper - - Murray Cod - - Green Tree Frog - - Cane Toad - - Redback Spider - - Funnel Web Spider - - Blue Ringed Octopus - - Fresh Water Crocodile - - Skink - - Thorny Devil - - King Brown Snake - - Carpet Python - - Tiger Snake - - Red Bellied Black Snake - - Blue Tongue Lizard - - Frilled Neck Lizard - - Saltwater Crocodile - - Eastern Brown Snake - states: - - New South Wales - - Queensland - - Western Australia - - Northern Territory - - South Australia - - Australian Capital Territory - - Victoria - - Tasmania + locations: + australia: + locations: + - Brisbane + - Sydney + - Melbourne + - Perth + - Adelaide + - Gold Coast + - Newcastle + - Canberra + - Central Coast + - Sunshine Coast + - Wollongong + - Geelong + - Hobart + - Townsville + - Cairns + - Toowoomba + - Darwin + - Ballarat + - Bendigo + - Albury + - Launceston + - Mackay + - Rockhampton + - Bunbury + - Coffs Harbour + - Bundaberg + - Melton + - Wagga Wagga + - Hervey Bay + - Mildura – Wentworth + - Shepparton – Mooroopna + - Port Macquarie + - Gladstone – Tannum Sands + - Tamworth + - Traralgon – Morwell + - Orange + - Bowral – Mittagong + - Busselton + - Geraldton + - Dubbo + - Nowra – Bomaderry + - Warragul – Drouin + - Bathurst + - Warrnambool + - Albany + - Kalgoorlie + - Devonport + - Mount Gambier + - Lismore + - Nelson Bay + animals: + - Koala + - Humpback Whale + - Australian Fur Seal + - Wallaby + - Platypus + - Kangaroo + - Wombat + - Sugar Glider + - Flying Fox + - Tasmanian Devil + - Quokka + - Dugong + - Luaner + - Echidna + - Magpie + - Cockatoo + - Tawny Frogmouth + - Galah + - Lorikeet + - Pelican + - Cassowary + - Kookaburra + - Emu + - Lyrebird + - Barramundi + - Grouper + - Murray Cod + - Green Tree Frog + - Cane Toad + - Redback Spider + - Funnel Web Spider + - Blue Ringed Octopus + - Fresh Water Crocodile + - Skink + - Thorny Devil + - King Brown Snake + - Carpet Python + - Tiger Snake + - Red Bellied Black Snake + - Blue Tongue Lizard + - Frilled Neck Lizard + - Saltwater Crocodile + - Eastern Brown Snake + states: + - New South Wales + - Queensland + - Western Australia + - Northern Territory + - South Australia + - Australian Capital Territory + - Victoria + - Tasmania From 865bddf52891fd6e793ad0e51d30ee2e2c505d54 Mon Sep 17 00:00:00 2001 From: Keshav Biswa Date: Tue, 19 Mar 2024 10:56:26 +0530 Subject: [PATCH 17/18] updated test to differentiate deprecated methods --- test/faker/locations/test_faker_australia.rb | 24 +++++++------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/test/faker/locations/test_faker_australia.rb b/test/faker/locations/test_faker_australia.rb index d4542ca8f0..4e78113d62 100644 --- a/test/faker/locations/test_faker_australia.rb +++ b/test/faker/locations/test_faker_australia.rb @@ -3,37 +3,29 @@ require_relative '../../test_helper' class TestFakerLocationsAustralia < Test::Unit::TestCase - def setup - @tester = Faker::Locations::Australia - end - def test_location - assert_match(/\w+/, @tester.location) + assert_match(/\w+/, Faker::Locations::Australia.location) end def test_animal - assert_match(/\w+/, @tester.animal) + assert_match(/\w+/, Faker::Locations::Australia.animal) end def test_state - assert_match(/\w+/, @tester.state) + assert_match(/\w+/, Faker::Locations::Australia.state) end end class TestFakerAustralia < Test::Unit::TestCase - def setup - @tester = Faker::Australia - end - - def test_location - assert_match(/\w+/, @tester.location) + def test_deprecated_location + assert_match(/\w+/, Faker::Australia.location) end - def test_animal - assert_match(/\w+/, @tester.animal) + def test_deprecated_animal + assert_match(/\w+/, Faker::Australia.animal) end def test_state - assert_match(/\w+/, @tester.state) + assert_match(/\w+/, Faker::Australia.state) end end From 391399c5f3ce9417e1a946c9e08aa98c79256e61 Mon Sep 17 00:00:00 2001 From: Keshav Biswa Date: Tue, 19 Mar 2024 20:51:47 +0530 Subject: [PATCH 18/18] Removed whitespaces from australia.yml --- lib/locales/en/australia.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/locales/en/australia.yml b/lib/locales/en/australia.yml index 25df41ebc0..eb64d5be7f 100644 --- a/lib/locales/en/australia.yml +++ b/lib/locales/en/australia.yml @@ -30,7 +30,7 @@ en: - Coffs Harbour - Bundaberg - Melton - - Wagga Wagga + - Wagga Wagga - Hervey Bay - Mildura – Wentworth - Shepparton – Mooroopna