From a40905f2ae20a1dcd153722640c9f1ee96e499bf Mon Sep 17 00:00:00 2001 From: Blake Astley <46544374+astley92@users.noreply.github.com> Date: Sat, 21 Aug 2021 23:44:54 +1000 Subject: [PATCH] Add Faker::Australia class (#2245) * Add initial test * Add Australia class and first method locations * Add 50 australian locations * Add Australian animals * Rename folder * Add Australian States * Fix typos * Fix more typos * Fix spacing * Add faker version documentation --- lib/faker/locations/australia.rb | 47 +++++++++ lib/locales/en/australia.yml | 108 ++++++++++++++++++++ test/faker/location/test_faker_australia.rb | 21 ++++ 3 files changed, 176 insertions(+) create mode 100644 lib/faker/locations/australia.rb create mode 100644 lib/locales/en/australia.yml create mode 100644 test/faker/location/test_faker_australia.rb diff --git a/lib/faker/locations/australia.rb b/lib/faker/locations/australia.rb new file mode 100644 index 0000000000..c0aeadf597 --- /dev/null +++ b/lib/faker/locations/australia.rb @@ -0,0 +1,47 @@ +# 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 + + # Produces an Australian animal + # + # @return [String] + # + # @example + # Faker::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') + end + end + end +end diff --git a/lib/locales/en/australia.yml b/lib/locales/en/australia.yml new file mode 100644 index 0000000000..0ac977c2ff --- /dev/null +++ b/lib/locales/en/australia.yml @@ -0,0 +1,108 @@ +en: + faker: + australia: + locations: + - Brisbane + - Sydney + - Melbourne + - Brisbane + - 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 + - Visctoria + - Tasmania diff --git a/test/faker/location/test_faker_australia.rb b/test/faker/location/test_faker_australia.rb new file mode 100644 index 0000000000..5d58c03e57 --- /dev/null +++ b/test/faker/location/test_faker_australia.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require_relative '../../test_helper' + +class TestFakerAustralia < Test::Unit::TestCase + def setup + @tester = Faker::Australia + end + + def test_location + assert @tester.location.match(/\w+/) + end + + def test_animal + assert @tester.animal.match(/\w+/) + end + + def test_state + assert @tester.state.match(/\w+/) + end +end