Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/default/placeholdit.md
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 3 additions & 0 deletions lib/faker/default/placeholdit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Faker
class Placeholdit < Base
class << self
extend Gem::Deprecate

SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze

##
Expand Down Expand Up @@ -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

Expand Down
18 changes: 18 additions & 0 deletions test/faker/default/test_placeholdit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down