Skip to content

Commit

Permalink
Add Faker::Football (faker-ruby#1189)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AlexGascon authored and vbrazo committed May 15, 2018
1 parent 3eb25a0 commit 17994e1
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions doc/football.md
Original file line number Diff line number Diff line change
@@ -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"
```

21 changes: 21 additions & 0 deletions lib/faker/football.rb
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions lib/locales/en/football.yml
Original file line number Diff line number Diff line change
@@ -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"]
23 changes: 23 additions & 0 deletions test/test_faker_football.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 17994e1

Please sign in to comment.