From 9dcb54d19006c7bd2d5016a1551812d471ce74d5 Mon Sep 17 00:00:00 2001 From: Augusto Xavier Date: Wed, 10 Jun 2026 15:25:48 -0300 Subject: [PATCH] Deprecate Faker::Placeholdit in favor of Faker::LoremFlickr.image The via.placeholder.com service no longer resolves, so the URLs generated by Faker::Placeholdit are broken. Per maintainer guidance in the issue and the project's decision to move away from generators that rely on external services (#2852), deprecate the generator instead of pointing it at another third-party host, so it can be removed in a future release. Faker::Placeholdit.image keeps working and returns the same values; it now emits a deprecation warning recommending Faker::LoremFlickr.image. [Fix #3055] --- doc/default/placeholdit.md | 3 +++ lib/faker/default/placeholdit.rb | 3 +++ test/faker/default/test_placeholdit.rb | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/doc/default/placeholdit.md b/doc/default/placeholdit.md index 266fba4eba..b9dc8aea5b 100644 --- a/doc/default/placeholdit.md +++ b/doc/default/placeholdit.md @@ -1,5 +1,8 @@ # Faker::Placeholdit +> [!WARNING] +> `Faker::Placeholdit` is deprecated and will be removed in a future version. The via.placeholder.com service is no longer available. Use [`Faker::LoremFlickr`](lorem_flickr.md) instead. + ```ruby # Keyword arguments: size, format, background_color, text_color, text Faker::Placeholdit.image #=> "https://via.placeholder.com/300x300.png" diff --git a/lib/faker/default/placeholdit.rb b/lib/faker/default/placeholdit.rb index 28eb6c84e9..eac6256b60 100644 --- a/lib/faker/default/placeholdit.rb +++ b/lib/faker/default/placeholdit.rb @@ -3,6 +3,8 @@ module Faker class Placeholdit < Base class << self + extend Gem::Deprecate + SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze ## @@ -41,6 +43,7 @@ def image(size: '300x300', format: 'png', background_color: nil, text_color: nil image_url += "?text=#{text}" if text image_url end + deprecate :image, 'Faker::LoremFlickr.image', 2026, 12 private diff --git a/test/faker/default/test_placeholdit.rb b/test/faker/default/test_placeholdit.rb index 1edef5481e..84fa319688 100644 --- a/test/faker/default/test_placeholdit.rb +++ b/test/faker/default/test_placeholdit.rb @@ -5,6 +5,24 @@ class TestPlaceholdit < Test::Unit::TestCase def setup @tester = Faker::Placeholdit + @original_skip = Gem::Deprecate.skip + Gem::Deprecate.skip = true + end + + def teardown + Gem::Deprecate.skip = @original_skip + end + + def test_image_is_deprecated + Gem::Deprecate.skip = false + original_stderr = $stderr + $stderr = StringIO.new + + @tester.image + + assert_match(/Placeholdit\.image is deprecated; use Faker::LoremFlickr\.image instead/, $stderr.string) + ensure + $stderr = original_stderr end def test_placeholdit