Skip to content

Commit

Permalink
Deprecate LoremPixel (#2590)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
uzorjchibuzor committed Nov 1, 2022
1 parent adda481 commit c656412
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/faker/default/lorem_pixel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Faker
class LoremPixel < Base
class << self
extend Gem::Deprecate

SUPPORTED_CATEGORIES = %w[abstract
animals
business
Expand Down Expand Up @@ -55,6 +57,7 @@ def image(size: '300x300', is_gray: false, category: nil, number: nil, text: nil
url_parts += [category, number, text].compact
url_parts.join('/')
end
deprecate :image, 'Faker::LoremFlickr.image', 2022, 12
# rubocop:enable Metrics/ParameterLists
end
end
Expand Down
8 changes: 8 additions & 0 deletions test/faker/default/test_lorem_pixel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ def setup
@tester = Faker::LoremPixel
end

def test_image_deprecation_message
_out, err = capture_output do
@tester.image(size: '3x3')
end

assert_match(/Faker::LoremPixel.image is deprecated; use Faker::LoremFlickr.image instead\./, err)
end

def test_lorempixel
refute_nil @tester.image.match(%r{https://lorempixel\.com/(\d+/\d+)})[1]
end
Expand Down

0 comments on commit c656412

Please sign in to comment.