From 06c935b126b5b1d86dcf7946f9f97d84c7503e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gasc=C3=B3n?= Date: Tue, 15 May 2018 07:47:44 +0200 Subject: [PATCH] Add Faker::Football (#1189) * Adding Faker::Football * Adding tests * Adding football specific documentation and including link to it on README.md * Fixing name of football coaches locale * Fixing typo in tests - Changing 'asssert' for 'assert' * Adding football data * Fixing Tottenham Hotspur name --- README.md | 1 + doc/football.md | 12 ++++++++++++ lib/faker/football.rb | 21 +++++++++++++++++++++ lib/locales/en/football.yml | 7 +++++++ test/test_faker_football.rb | 23 +++++++++++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 doc/football.md create mode 100644 lib/faker/football.rb create mode 100644 lib/locales/en/football.yml create mode 100644 test/test_faker_football.rb diff --git a/README.md b/README.md index 798c12b8ab..4c8283bdb3 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Contents - [Faker::File](doc/file.md) - [Faker::Fillmurray](doc/fillmurray.md) - [Faker::Food](doc/food.md) + - [Faker::Football](doc/football.md) - [Faker::Friends](doc/friends.md) - [Faker::GameOfThrones](doc/game_of_thrones.md) - [Faker::Gender](doc/gender.md) diff --git a/doc/football.md b/doc/football.md new file mode 100644 index 0000000000..2721b62f44 --- /dev/null +++ b/doc/football.md @@ -0,0 +1,12 @@ +# Faker::Football + +```ruby +Faker::Football.team #=> "Manchester United" + +Faker::Football.player #=> "Lionel Messi" + +Faker::Football.coach #=> "Jose Mourinho" + +Faker::Football.competition #=> "FIFA World Cup" +``` + diff --git a/lib/faker/football.rb b/lib/faker/football.rb new file mode 100644 index 0000000000..61cbbbd156 --- /dev/null +++ b/lib/faker/football.rb @@ -0,0 +1,21 @@ +module Faker + class Football < Base + class << self + def team + fetch('football.teams') + end + + def player + fetch('football.players') + end + + def coach + fetch('football.coaches') + end + + def competition + fetch('football.competitions') + end + end + end +end diff --git a/lib/locales/en/football.yml b/lib/locales/en/football.yml new file mode 100644 index 0000000000..89650fdc07 --- /dev/null +++ b/lib/locales/en/football.yml @@ -0,0 +1,7 @@ +en: + faker: + football: + teams: ["Real Madrid", "FC Barcelona", "Valencia CF", "Atletico Madrid", "Manchester United", "Chelsea", "Liverpool", "Arsenal", "Tottenham Hotspur", "AC Milan", "Inter Milan", "AS Roma", "Juventus", "Bayern Munich", "Borussia Dortmund", "Schalke 04", "Benfica", "Galatasaray", "PSV Eindhoven", "LA Galaxy"] + players: ["Lionel Messi", "Gerard Pique", "Sergio Ramos", "Cristiano Ronaldo", "David De Gea", "Paul Pogba", "Antoine Griezmann", "Alvaro Morata", "Andres Iniesta", "Roberto Firmino", "Mohammed Salah", "Harry Kane", "Delle Alli", "Arjen Robben", "Franck Ribery", "Marco Reus", "Robert Lewandoski", "Zlatan Ibrahimovic", "Edinson Cavani", "Sergio Aguero", "Neymar", "Mesut Ozil", "Gianluigi Buffon", "Willian", "Manuel Neuer", "Juan Mata", "Manuel Neuer", "Cesc Fabregas", "Gareth Bale", "Eden Hazard", "Mario Mandzukic"] + coaches: ["Ernesto Valverde", "Zinedine Zidane", "Jose Mourinho", "Antonio Conte", "Jurgen Klopp", "Mauricio Pochettino", "Diego Simeone", "Massimiliano Allegri", "Jupp Heyneckes", "Arsene Wenger", "Jorge Sampaoli", "Fernando Santos", "Didier Deschamps", "Joachim Low", "Julen Lopetegui", "Mauricio Pochettino", "Unai Emery", "Massimiliano Allegri", "UEFA European Championship", "Asian Cup", "African Cup of Nations", "Copa America" ] + competitions: ["UEFA Champions League", "FIFA World Cup", "UEFA Europa League", "Serie A", "Barclays Premier League", "Bundesliga", "Liga Santander", "FA Cup", "Ligue 1", "Primeira Liga", "Eredivisie", "Super League", "Major League Soccer", "Coppa Italia", "DFB Pokal", "CONCACAF Gold Cup", "Nations Cup", "Copa del Rey"] diff --git a/test/test_faker_football.rb b/test/test_faker_football.rb new file mode 100644 index 0000000000..0d0cd0f43f --- /dev/null +++ b/test/test_faker_football.rb @@ -0,0 +1,23 @@ +require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb') + +class TestFakerFootball < Test::Unit::TestCase + def setup + @tester = Faker::Football + end + + def test_team + assert @tester.team.match(/\w+/) + end + + def test_player + assert @tester.player.match(/\w+/) + end + + def test_coach + assert @tester.coach.match(/\w+/) + end + + def test_competition + assert @tester.competition.match(/\w+/) + end +end