Skip to content

Commit

Permalink
Deprecate Fillmurray service
Browse files Browse the repository at this point in the history
  • Loading branch information
ferblape committed Dec 28, 2022
1 parent 4367d4e commit e4b8f4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/faker/default/fillmurray.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ class << self
# #=> "https://fillmurray.com/200/400"
#
# @faker.version 1.7.1
extend Gem::Deprecate
def image(grayscale: false, width: 200, height: 200)
raise ArgumentError, 'Width should be a number' unless width.to_s =~ /^\d+$/
raise ArgumentError, 'Height should be a number' unless height.to_s =~ /^\d+$/
raise ArgumentError, 'Grayscale should be a boolean' unless [true, false].include?(grayscale)

"https://www.fillmurray.com#{'/g' if grayscale == true}/#{width}/#{height}"
end
deprecate :image, 'Faker::LoremFlickr.image', 2022, 12
end
end
end
8 changes: 8 additions & 0 deletions test/faker/default/test_faker_fillmurray.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ def test_fillmurray
refute_nil @tester.image(grayscale: false, width: '300', height: '300').match(%r{https://www\.fillmurray\.com/(\d+)/(\d+)})
end

def test_image_deprecation_message
_out, err = capture_output do
@tester.image(grayscale: false, width: '300', height: '300')
end

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

def test_fillmurray_with_grayscale
assert_equal('g/', @tester.image(grayscale: true, width: '300', height: '300').match(%r{https://www\.fillmurray\.com/(g?/?)(\d+)/(\d+)})[1])
end
Expand Down

0 comments on commit e4b8f4a

Please sign in to comment.