@@ -8,11 +8,11 @@ def setup
88 end
99
1010 def test_placeholdit
11- refute_nil @tester . image . match ( %r{https://via \. placeholder \. com /(.+)(png?)} ) [ 1 ]
11+ refute_nil @tester . image . match ( %r{https://placehold \. co /(.+)(png?)} ) [ 1 ]
1212 end
1313
1414 def test_avatar_with_custom_size
15- assert_equal ( '3x3' , @tester . image ( size : '3x3' ) . match ( %r{https://via \. placeholder \. com /+(\d +x\d +)} ) [ 1 ] )
15+ assert_equal ( '3x3' , @tester . image ( size : '3x3' ) . match ( %r{https://placehold \. co /+(\d +x\d +)} ) [ 1 ] )
1616 end
1717
1818 def test_avatar_with_incorrect_size
@@ -22,7 +22,7 @@ def test_avatar_with_incorrect_size
2222 end
2323
2424 def test_avatar_with_supported_format
25- assert_match %r{https://via \. placeholder \. com /(.+)(jpg?)} , @tester . image ( size : '300x300' , format : 'jpg' )
25+ assert_match %r{https://placehold \. co /(.+)(jpg?)} , @tester . image ( size : '300x300' , format : 'jpg' )
2626 end
2727
2828 def test_avatar_with_incorrect_format
@@ -31,16 +31,20 @@ def test_avatar_with_incorrect_format
3131 end
3232 end
3333
34+ def test_avatar_uses_000_as_text_when_only_specifying_background
35+ assert_match %r{https://placehold\. co/(.+)/ffffff/000} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'ffffff' )
36+ end
37+
3438 def test_avatar_background_with_correct_six_char_hex
35- assert_match %r{https://via \. placeholder \. com /(.+)(jpg? )/ffffff} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'ffffff' )
39+ assert_match %r{https://placehold \. co /(.+)/ffffff} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'ffffff' )
3640 end
3741
3842 def test_avatar_background_with_correct_three_char_hex
39- assert_match %r{https://via \. placeholder \. com /(.+)(jpg? )/fff} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'fff' )
43+ assert_match %r{https://placehold \. co /(.+)/fff} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'fff' )
4044 end
4145
4246 def test_avatar_background_with_random_color
43- assert_match %r{https://via \. placeholder \. com /(.+)(jpg?) /[a-f0-9]{6}} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : :random )
47+ assert_match %r{https://placehold \. co /(.+)/[a-f0-9]{6}/000 } , @tester . image ( size : '300x300' , format : 'jpg' , background_color : :random )
4448 end
4549
4650 def test_avatar_background_with_wrong_six_char_hex
@@ -61,16 +65,20 @@ def test_avatar_background_with_wrong_three_char_hex
6165 end
6266 end
6367
68+ def test_avatar_uses_fff_as_background_when_only_specifying_font_color
69+ assert_match %r{https://placehold\. co/(.+)/fff/000000} , @tester . image ( size : '300x300' , format : 'jpg' , text_color : '000000' )
70+ end
71+
6472 def test_avatar_font_color_with_correct_six_char_hex
65- assert_match %r{https://via \. placeholder \. com /(.+)(jpg? )/ffffff/000000} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'ffffff' , text_color : '000000' )
73+ assert_match %r{https://placehold \. co /(.+)/ffffff/000000} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'ffffff' , text_color : '000000' )
6674 end
6775
6876 def test_avatar_font_color_with_correct_three_char_hex
69- assert_match %r{https://via \. placeholder \. com /(.+)(jpg? )/fff} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'fff' , text_color : '000' )
77+ assert_match %r{https://placehold \. co /(.+)/fff} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'fff' , text_color : '000' )
7078 end
7179
7280 def test_avatar_font_color_with_random_color
73- assert_match %r{https://via \. placeholder \. com /(.+)(jpg? )/fff/[a-f0-9]{6}} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'fff' , text_color : :random )
81+ assert_match %r{https://placehold \. co /(.+)/fff/[a-f0-9]{6}} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'fff' , text_color : :random )
7482 end
7583
7684 def test_avatar_font_color_with_wrong_six_char_hex
@@ -92,10 +100,10 @@ def test_avatar_font_color_with_wrong_three_char_hex
92100 end
93101
94102 def test_text_not_present
95- assert_match %r{https://via \. placeholder \. com /[^\\ ?]+$} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'fff' , text_color : '000' )
103+ assert_match %r{https://placehold \. co /[^\\ ?]+$} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'fff' , text_color : '000' )
96104 end
97105
98106 def test_text_present
99- assert_match %r{https://via \. placeholder \. com /(.+)\? text=hello} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'fff' , text_color : '000' , text : 'hello' )
107+ assert_match %r{https://placehold \. co /(.+)\? text=hello} , @tester . image ( size : '300x300' , format : 'jpg' , background_color : 'fff' , text_color : '000' , text : 'hello' )
100108 end
101109end
0 commit comments