Skip to content

Commit 7cfabab

Browse files
authored
Deprecate FillMurray service (#2657)
* Deprecate Fillmurray service * Update date * Skip deprecation message
1 parent f8b0837 commit 7cfabab

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

lib/faker/default/fillmurray.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ class << self
2424
# #=> "https://fillmurray.com/200/400"
2525
#
2626
# @faker.version 1.7.1
27+
extend Gem::Deprecate
2728
def image(grayscale: false, width: 200, height: 200)
2829
raise ArgumentError, 'Width should be a number' unless width.to_s =~ /^\d+$/
2930
raise ArgumentError, 'Height should be a number' unless height.to_s =~ /^\d+$/
3031
raise ArgumentError, 'Grayscale should be a boolean' unless [true, false].include?(grayscale)
3132

3233
"https://www.fillmurray.com#{'/g' if grayscale == true}/#{width}/#{height}"
3334
end
35+
deprecate :image, 'Faker::LoremFlickr.image', 2023, 2
3436
end
3537
end
3638
end

test/faker/default/test_faker_fillmurray.rb

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,46 @@ def setup
88
end
99

1010
def test_fillmurray
11-
refute_nil @tester.image(grayscale: false, width: '300', height: '300').match(%r{https://www\.fillmurray\.com/(\d+)/(\d+)})
11+
Gem::Deprecate.skip_during do
12+
refute_nil @tester.image(grayscale: false, width: '300', height: '300').match(%r{https://www\.fillmurray\.com/(\d+)/(\d+)})
13+
end
14+
end
15+
16+
def test_image_deprecation_message
17+
_out, err = capture_output do
18+
@tester.image(grayscale: false, width: '300', height: '300')
19+
end
20+
21+
assert_match(/Faker::Fillmurray.image is deprecated; use Faker::LoremFlickr.image instead\./, err)
1222
end
1323

1424
def test_fillmurray_with_grayscale
15-
assert_equal('g/', @tester.image(grayscale: true, width: '300', height: '300').match(%r{https://www\.fillmurray\.com/(g?/?)(\d+)/(\d+)})[1])
25+
Gem::Deprecate.skip_during do
26+
assert_equal('g/', @tester.image(grayscale: true, width: '300', height: '300').match(%r{https://www\.fillmurray\.com/(g?/?)(\d+)/(\d+)})[1])
27+
end
1628
end
1729

1830
def test_fillmurray_with_incorrect_height_format
19-
assert_raise ArgumentError do
20-
@tester.image(grayscale: false, width: '300', height: 'nine-thousand')
31+
Gem::Deprecate.skip_during do
32+
assert_raise ArgumentError do
33+
@tester.image(grayscale: false, width: '300', height: 'nine-thousand')
34+
end
2135
end
2236
end
2337

2438
def test_fillmurray_with_incorrect_width_format
25-
assert_raise ArgumentError do
26-
@tester.image(grayscale: false, width: 'three-hundred')
39+
Gem::Deprecate.skip_during do
40+
assert_raise ArgumentError do
41+
@tester.image(grayscale: false, width: 'three-hundred')
42+
end
2743
end
2844
end
2945

3046
def test_fillmurray_with_incorrect_grayscale
31-
assert_raise ArgumentError do
32-
@tester.image(grayscale: 'gray', width: '300', height: '400')
47+
Gem::Deprecate.skip_during do
48+
assert_raise ArgumentError do
49+
@tester.image(grayscale: 'gray', width: '300', height: '400')
50+
end
3351
end
3452
end
3553
end

test/test_determinism.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@ def setup
1010

1111
def test_determinism
1212
Faker::Config.random = Random.new(42)
13-
@all_methods.each_index do |index|
14-
store_result @all_methods[index]
15-
end
1613

17-
@first_run.freeze
14+
Gem::Deprecate.skip_during do
15+
@all_methods.each_index do |index|
16+
store_result @all_methods[index]
17+
end
1818

19-
Faker::Config.random = Random.new(42)
19+
@first_run.freeze
2020

21-
@all_methods.each_index do |index|
22-
assert deterministic_random? @first_run[index], @all_methods[index]
21+
Faker::Config.random = Random.new(42)
22+
23+
@all_methods.each_index do |index|
24+
assert deterministic_random? @first_run[index], @all_methods[index]
25+
end
2326
end
2427
end
2528

0 commit comments

Comments
 (0)