diff --git a/doc/default/food.md b/doc/default/food.md index 8ee47c013d..b93cfddb1e 100644 --- a/doc/default/food.md +++ b/doc/default/food.md @@ -3,6 +3,8 @@ Available since version 1.7.0. ```ruby +Faker::Food.allergen #=> "Peanuts" + Faker::Food.description #=> "Three eggs with cilantro, tomatoes, onions, avocados and melted Emmental cheese. With a side of roasted potatoes, and your choice of toast or croissant." Faker::Food.dish #=> "Caesar Salad" diff --git a/lib/faker/default/food.rb b/lib/faker/default/food.rb index a05ccc5826..945c1aa508 100644 --- a/lib/faker/default/food.rb +++ b/lib/faker/default/food.rb @@ -5,6 +5,19 @@ class Food < Base flexible :food class << self + ## + # Retrieves an allergen. + # + # @return [String] + # + # @example + # Faker::Food.allergen #=> "Peanuts" + # + # @faker.version next + def allergen + fetch('food.allergens') + end + ## # Retrieves a typical dish from each country. # diff --git a/lib/locales/en/food.yml b/lib/locales/en/food.yml index be0b326f3b..6f64e456b3 100644 --- a/lib/locales/en/food.yml +++ b/lib/locales/en/food.yml @@ -1,6 +1,18 @@ en: faker: food: + allergens: + - Eggs + - Milk + - Mustard + - Peanuts + - Crustaceans and molluscs + - Fish + - Sesame seeds + - Soy + - Sulphites + - Tree Nuts + - Wheat and triticale dish: - Arepas - Barbecue Ribs diff --git a/test/faker/default/test_faker_food.rb b/test/faker/default/test_faker_food.rb index c050fb2e79..6c31f8b7d1 100644 --- a/test/faker/default/test_faker_food.rb +++ b/test/faker/default/test_faker_food.rb @@ -11,6 +11,10 @@ def test_flexible_key assert_equal(:food, @tester.flexible_key) end + def test_allergen + assert_match(/\w+/, @tester.allergen) + end + def test_dish assert_match(/\w+/, @tester.dish) end