Skip to content

Commit c656412

Browse files
Deprecate LoremPixel (#2590)
* added deprecation warning * included serach terms in method call * test for lorem_pixel redirection to loremflickr with options * used Gem::Deprecate to show warning message * deprecation message showing end of year * test for deprecation warning * fix rubocop offences * simplified test for deprecation * fix rubocop offense on the test file
1 parent adda481 commit c656412

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/faker/default/lorem_pixel.rb

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
module Faker
44
class LoremPixel < Base
55
class << self
6+
extend Gem::Deprecate
7+
68
SUPPORTED_CATEGORIES = %w[abstract
79
animals
810
business
@@ -55,6 +57,7 @@ def image(size: '300x300', is_gray: false, category: nil, number: nil, text: nil
5557
url_parts += [category, number, text].compact
5658
url_parts.join('/')
5759
end
60+
deprecate :image, 'Faker::LoremFlickr.image', 2022, 12
5861
# rubocop:enable Metrics/ParameterLists
5962
end
6063
end

test/faker/default/test_lorem_pixel.rb

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ def setup
77
@tester = Faker::LoremPixel
88
end
99

10+
def test_image_deprecation_message
11+
_out, err = capture_output do
12+
@tester.image(size: '3x3')
13+
end
14+
15+
assert_match(/Faker::LoremPixel.image is deprecated; use Faker::LoremFlickr.image instead\./, err)
16+
end
17+
1018
def test_lorempixel
1119
refute_nil @tester.image.match(%r{https://lorempixel\.com/(\d+/\d+)})[1]
1220
end

0 commit comments

Comments
 (0)