1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287
|
# frozen_string_literal: true
require_relative 'spec_helper'
describe 'Asciidoctor::PDF::Converter - Admonition' do
it 'should advance unbreakable block shorter than page to next page to avoid splitting it' do
pdf = to_pdf <<~EOS, analyze: true
#{(['paragraph'] * 20).join %(\n\n)}
[NOTE%unbreakable]
====
#{(['admonition'] * 20).join %(\n\n)}
====
EOS
admon_page_numbers = (pdf.find_text 'admonition').map {|it| it[:page_number] }.uniq
(expect admon_page_numbers).to eql [2]
end
it 'should place anchor directly at top of block' do
input = <<~EOS
paragraph
[NOTE#admon-1]
====
filler
====
EOS
lines = (to_pdf input, analyze: :line).lines
pdf = to_pdf input
(expect (dest = get_dest pdf, 'admon-1')).not_to be_nil
(expect dest[:y]).to eql lines[0][:from][:y]
end
it 'should offset anchor from top of block by amount of block_anchor_top' do
pdf_theme = { block_anchor_top: -12 }
input = <<~EOS
paragraph
[NOTE#admon-1]
====
filler
====
EOS
lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines
pdf = to_pdf input, pdf_theme: pdf_theme
(expect (dest = get_dest pdf, 'admon-1')).not_to be_nil
(expect dest[:y]).to eql (lines[0][:from][:y] + -pdf_theme[:block_anchor_top])
end
it 'should keep anchor with block if block is advanced to next page' do
input = <<~EOS
paragraph
[NOTE#admon-1%unbreakable]
====
#{(['filler'] * 27).join %(\n\n)}
====
EOS
lines = (to_pdf input, analyze: :line).lines
pdf = to_pdf input
(expect (dest = get_dest pdf, 'admon-1')).not_to be_nil
(expect dest[:page_number]).to be 2
(expect dest[:y]).to eql lines[0][:from][:y]
end
it 'should vertically center label on first page if block is split across pages' do
pdf = to_pdf <<~EOS, pdf_theme: { page_margin: '0.5in' }, analyze: true
[NOTE]
====
#{(['admonition'] * 40).join %(\n\n)}
====
EOS
(expect pdf.pages).to have_size 2
page_height = (get_page_size pdf)[1]
label_text = (pdf.find_text 'NOTE')[0]
label_text_midpoint = label_text[:y] + (label_text[:font_size] * 0.5)
(expect label_text_midpoint).to be_within(2).of(page_height * 0.5)
end
it 'should draw vertical rule on all pages if block is split across pages' do
pdf = to_pdf <<~EOS, pdf_theme: { page_margin: '0.5in' }, analyze: :line
[NOTE]
====
#{(['admonition'] * 40).join %(\n\n)}
====
EOS
lines = pdf.lines
(expect lines).to have_size 2
(expect lines.map {|it| it[:page_number] }).to eql [1, 2]
(expect lines[0][:to][:y]).to eql 36.0
(expect lines[1][:to][:y]).to be > 36.0
end
it 'should draw border and background on all pages if block is split across pages', visual: true do
pdf_theme = {
admonition_background_color: 'F5A9A9',
admonition_border_width: 0.5,
admonition_border_color: '333333',
admonition_rule_color: 'FFFFFF',
}
to_file = to_pdf_file <<~EOS, 'admonition-page-split.pdf', pdf_theme: pdf_theme
before
[NOTE]
====
#{(['admonition'] * 40).join %(\n\n)}
====
after
EOS
(expect to_file).to visually_match 'admonition-page-split.pdf'
end
it 'should not collapse bottom padding if block ends near bottom of page' do
pdf_theme = {
admonition_padding: 12,
admonition_background_color: 'EEEEEE',
admonition_column_rule_width: 0,
}
pdf = with_content_spacer 10, 690 do |spacer_path|
to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true
image::#{spacer_path}[]
[NOTE]
====
content +
that wraps
====
EOS
end
pages = pdf.pages
(expect pages).to have_size 1
gs = pdf.extract_graphic_states pages[0][:raw_content]
(expect gs[1]).to have_background color: 'EEEEEE', top_left: [48.24, 103.89], bottom_right: [48.24, 48.33]
last_text_y = pdf.text[-1][:y]
(expect last_text_y - pdf_theme[:admonition_padding]).to be > 48.24
pdf = with_content_spacer 10, 692 do |spacer_path|
to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true
image::#{spacer_path}[]
[NOTE]
====
content +
that wraps
====
EOS
end
pages = pdf.pages
(expect pages).to have_size 2
gs = pdf.extract_graphic_states pages[0][:raw_content]
(expect gs[1]).to have_background color: 'EEEEEE', top_left: [48.24, 101.89], bottom_right: [48.24, 48.24]
(expect pdf.text[1][:page_number]).to eql 1
(expect pdf.text[2][:page_number]).to eql 2
(expect pdf.text[1][:y] - pdf_theme[:admonition_padding]).to be > 48.24
end
it 'should allow theme to configure properties of caption' do
pdf_theme = {
admonition_caption_font_color: '00AA00',
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
.Admonition title
[NOTE]
====
There's something you should know.
====
EOS
title_text = (pdf.find_text 'Admonition title')[0]
(expect title_text[:font_color]).to eql '00AA00'
end
it 'should use value of caption attribute as label' do
pdf = to_pdf <<~'EOS', analyze: true
[NOTE,caption=Pro Tip]
Use bundler!
EOS
label_text = pdf.text[0]
(expect label_text[:font_name]).to eql 'NotoSerif-Bold'
(expect label_text[:string]).to eql 'PRO TIP'
end
it 'should not transform label text if admonition_label_text_transform key is nil, none, or invalid' do
[nil, 'none', 'invalid'].each do |transform|
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_label_text_transform: transform }, analyze: true
[NOTE,caption=Pro Tip]
Use bundler!
EOS
label_text = pdf.text[0]
(expect label_text[:font_name]).to eql 'NotoSerif-Bold'
(expect label_text[:string]).to eql 'Pro Tip'
end
end
# TODO: this could use a deeper assertion
it 'should compute width of label even when glyph is missing' do
pdf = to_pdf <<~'EOS', analyze: true
[TIP,caption=⏻ Tip]
Use bundler!
EOS
label_text = pdf.text[0]
(expect label_text[:font_name]).to eql 'NotoSerif-Bold'
(expect label_text[:string]).to eql '⏻ TIP'
end
it 'should resize label text to fit if it overflows available space' do
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_label_font_size: 18 }, analyze: true
[IMPORTANT]
Make sure the device is powered off before servicing it.
EOS
label_text = pdf.find_unique_text 'IMPORTANT'
(expect label_text).not_to be_nil
(expect label_text[:font_size]).to be < 18
end
it 'should allow padding to be specified for label and content using single value' do
input = <<~'EOS'
[IMPORTANT]
Make sure the device is powered off before servicing it.
EOS
pdf = to_pdf input, pdf_theme: { admonition_padding: 0, admonition_label_padding: 0 }, analyze: true
ref_label_text = pdf.find_unique_text 'IMPORTANT'
ref_content_text = pdf.find_unique_text 'Make sure the device is powered off before servicing it.'
pdf = to_pdf input, pdf_theme: { admonition_padding: 10, admonition_label_padding: 10 }, analyze: true
label_text = pdf.find_unique_text 'IMPORTANT'
content_text = pdf.find_unique_text 'Make sure the device is powered off before servicing it.'
(expect (label_text[:x] - ref_label_text[:x]).round 4).to eql 10.0
(expect (content_text[:x] - ref_content_text[:x]).round 4).to eql 30.0
end
it 'should allow padding to be specified for label and content using array value' do
input = <<~'EOS'
[IMPORTANT]
Make sure the device is powered off before servicing it.
EOS
pdf = to_pdf input, pdf_theme: { admonition_padding: 0, admonition_label_padding: 0 }, analyze: true
ref_label_text = pdf.find_unique_text 'IMPORTANT'
ref_content_text = pdf.find_unique_text 'Make sure the device is powered off before servicing it.'
pdf = to_pdf input, pdf_theme: { admonition_padding: [nil, 10], admonition_label_padding: [nil, 10] }, analyze: true
label_text = pdf.find_unique_text 'IMPORTANT'
content_text = pdf.find_unique_text 'Make sure the device is powered off before servicing it.'
(expect (label_text[:x] - ref_label_text[:x]).round 4).to eql 10.0
(expect (content_text[:x] - ref_content_text[:x]).round 4).to eql 30.0
end
it 'should not move cursor below block if block ends at top of page' do
pdf = to_pdf <<~'EOS', analyze: true
top of page
[NOTE]
====
something to remember
<<<
====
top of page
EOS
top_of_page_texts = pdf.find_text 'top of page'
(expect top_of_page_texts).to have_size 2
(expect top_of_page_texts[0][:y]).to eql top_of_page_texts[0][:y]
end
it 'should not allow prose_margin_bottom to impact padding' do
input = <<~'EOS'
NOTE: The prose_margin_bottom value does not impact the padding around the content box.
EOS
pdf = to_pdf input, pdf_theme: { prose_margin_bottom: 12 }, analyze: :line
reference_line = pdf.lines[0]
reference_text = (to_pdf input, pdf_theme: { prose_margin_bottom: 12 }, analyze: true).text[0]
pdf = to_pdf input, pdf_theme: { prose_margin_bottom: 24 }, analyze: :line
line = pdf.lines[0]
text = (to_pdf input, pdf_theme: { prose_margin_bottom: 24 }, analyze: true).text[0]
(expect line[:from][:y]).to eql reference_line[:from][:y]
(expect line[:to][:y]).to eql reference_line[:to][:y]
(expect text[:y]).to eql reference_text[:y]
end
it 'should not increment counter in admonition content more times than expected' do
pdf = to_pdf <<~'EOS', analyze: true
== Initial value
Current number is {counter:my-count:0}.
== One is expected
Current number is {counter:my-count}.
== Two is expected
Current number is {counter:my-count}.
== Three is expected
NOTE: Current number is {counter:my-count}.
== Four is expected
[%unbreakable]
CAUTION: Current number is {counter:my-count}.
== Five is expected
Current number is {counter:my-count}.
EOS
expected = (0.upto 5).map {|it| %(Current number is #{it}.) }
number_texts = pdf.find_text %r/^Current number is/
(expect number_texts.map {|it| it[:string] }).to eql expected
end
context 'Text' do
it 'should show admonition label in bold by default' do
pdf = to_pdf <<~'EOS', analyze: true
TIP: Look for the warp zone under the bridge.
EOS
lines = pdf.lines
(expect lines).to have_size 1
(expect lines[0]).to eql 'TIP Look for the warp zone under the bridge.'
text = pdf.text
(expect text).to have_size 2
label_text = text[0]
(expect label_text[:string]).to eql 'TIP'
(expect label_text[:font_name]).to eql 'NotoSerif-Bold'
content_text = text[1]
(expect content_text[:string]).to eql 'Look for the warp zone under the bridge.'
end
it 'should allow the theme to specify a minimum width for the text-based label' do
pdf_theme = {
admonition_label_min_width: '75',
admonition_label_text_align: 'right',
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
NOTE: Remember the milk.
TIP: Look for the warp zone under the bridge.
CAUTION: Slippery when wet.
WARNING: Beware of dog!
IMPORTANT: Sign off before stepping away from the computer.
EOS
label_texts = pdf.find_text font_name: 'NotoSerif-Bold'
label_right_reference = nil
label_texts.each do |it|
label_right_reference ||= it[:x] + it[:width]
(expect it[:x] + it[:width]).to be_within(1.5).of(label_right_reference)
end
content_texts = pdf.find_text font_name: 'NotoSerif'
(expect content_texts.map {|it| it[:x] }.uniq).to eql [content_texts[0][:x]]
end
it 'should allow theme to control vertical alignment of label' do
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_label_vertical_align: 'top' }, analyze: true
[NOTE]
====
There are lots of things you need to know.
Then there are the things that you already know.
And those things that you don't know that you do not know.
This documentation seeks to close the gaps between them.
====
EOS
label_text = (pdf.find_text 'NOTE')[0]
content_text = (pdf.find_text font_name: 'NotoSerif')[0]
(expect label_text[:y]).to be > content_text[:y]
end
it 'should resolve character references in label' do
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_label_font_color: '000000' }, analyze: true
[NOTE,caption=®]
====
Christoph and sons.
====
EOS
label_text = (pdf.find_text font_color: '000000')[0]
(expect label_text[:string]).to eql ?\u00ae
(expect label_text[:width]).to be < label_text[:font_size]
(expect label_text[:font_name]).to eql 'NotoSerif-Bold'
end
end
context 'Icon' do
it 'should show font-based icon in place of label when icons=font' do
pdf = to_pdf <<~'EOS', analyze: true
:icons: font
TIP: Look for the warp zone under the bridge.
EOS
lines = pdf.lines
(expect lines).to have_size 1
(expect lines[0]).to eql %(\uf0eb Look for the warp zone under the bridge.)
text = pdf.text
(expect text).to have_size 2
label_text = text[0]
(expect label_text[:string]).to eql ?\uf0eb
(expect label_text[:font_name]).to eql 'FontAwesome5Free-Regular'
# NOTE: font size is reduced to fit within available space
(expect label_text[:font_size]).to be < 24
content_text = text[1]
(expect content_text[:string]).to eql 'Look for the warp zone under the bridge.'
end
it 'should not reduce font size of icon if specified size fits within available space' do
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_important: { size: 50 } }, analyze: true
:icons: font
[IMPORTANT]
====
Always do this.
And when you do that, always do this too!
====
EOS
label_text = pdf.find_unique_text ?\uf06a
(expect label_text[:font_size]).to eql 50
end
it 'should allow the theme to specify a minimum width for the font-based icon label' do
pdf_theme = {
admonition_label_min_width: '75',
admonition_label_text_align: 'right',
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
:icons: font
NOTE: Remember the milk.
TIP: Look for the warp zone under the bridge.
CAUTION: Slippery when wet.
WARNING: Beware of dog!
IMPORTANT: Sign off before stepping away from the computer.
EOS
label_texts = pdf.text.select {|it| it[:font_name].start_with? 'FontAwesome' }
(expect label_texts[0][:x]).to be > 100
label_right_reference = nil
label_texts.each do |it|
label_right_reference ||= it[:x] + it[:width]
(expect it[:x] + it[:width]).to be_within(1.5).of(label_right_reference)
end
content_texts = pdf.find_text font_name: 'NotoSerif'
(expect content_texts.map {|it| it[:x] }.uniq).to eql [content_texts[0][:x]]
end
it 'should allow theme to control vertical alignment of icon' do
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_label_vertical_align: 'top' }, analyze: true
:icons: font
[NOTE]
====
There are lots of things you need to know.
Then there are the things that you already know.
And those things that you don't know that you do not know.
This documentation seeks to close the gaps between them.
====
EOS
icon_text = (pdf.find_text ?\uf05a)[0]
content_text = (pdf.find_text font_color: '333333')[1]
(expect icon_text[:y]).to be > content_text[:y]
end
it 'should assume icon name with no icon set prefix is a legacy FontAwesome icon name' do
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_tip: { name: 'smile-wink' } }, analyze: true
:icons: font
TIP: Time to upgrade your icon set.
EOS
icon_text = pdf.text[0]
(expect icon_text[:font_name]).to eql 'FontAwesome5Free-Solid'
(expect icon_text[:string]).to eql ?\uf4da
end
it 'should be able to use fa- prefix to reference icon in legacy FontAwesome set' do
(expect do
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_tip: { name: 'fa-smile-wink' } }, analyze: true
:icons: font
TIP: Time to upgrade your icon set.
EOS
icon_text = pdf.text[0]
(expect icon_text[:font_name]).to eql 'FontAwesome5Free-Solid'
(expect icon_text[:string]).to eql ?\uf4da
end).to log_message severity: :INFO, message: 'tip admonition in theme uses icon from deprecated fa icon set; use fas, far, or fab instead', using_log_level: :INFO
end
it 'should allow icon to come from Foundation icon set' do
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_warning: { name: 'fi-alert' } }, analyze: true
:icons: font
WARNING: Just don't do it.
EOS
icon_text = pdf.text[0]
(expect icon_text[:font_name]).to eql 'fontcustom'
(expect icon_text[:string]).to eql ?\uf101
end
it 'should fall back to note icon if icon name cannot be resolved' do
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_warning: { name: nil } }, analyze: true
:icons: font
WARNING: If the icon name is nil, the default note icon will be used.
EOS
icon_text = pdf.text[0]
(expect icon_text[:font_name]).to eql 'FontAwesome5Free-Solid'
(expect icon_text[:string]).to eql ?\uf05a
end
it 'should set color of icon to value of stroke_color key specified in theme' do
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_note: { stroke_color: '00ff00' } }, analyze: true
:icons: font
NOTE: This icon is green.
EOS
icon_text = (pdf.find_text ?\uf05a)[0]
(expect icon_text[:font_color]).to eql '00FF00'
end
it 'should use icon glyph specified in theme' do
pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_tip: { name: 'far-money-bill-alt' } }, analyze: true
:icons: font
TIP: Look for the warp zone under the bridge.
EOS
lines = pdf.lines
(expect lines).to have_size 1
(expect lines[0]).to eql %(\uf3d1 Look for the warp zone under the bridge.)
text = pdf.text
(expect text).to have_size 2
label_text = text[0]
(expect label_text[:string]).to eql ?\uf3d1
(expect label_text[:font_name]).to eql 'FontAwesome5Free-Regular'
content_text = text[1]
(expect content_text[:string]).to eql 'Look for the warp zone under the bridge.'
end
it 'should use SVG icon specified by icon attribute when icons attribute is set', visual: true do
to_file = to_pdf_file <<~'EOS', 'admonition-custom-svg-icon.pdf', attribute_overrides: { 'docdir' => fixtures_dir }
:icons: font
:iconsdir:
:icontype: svg
[TIP,icon=square]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
(expect to_file).to visually_match 'admonition-custom-svg-icon.pdf'
end
it 'should position SVG icon specified by icon attribute in correct column when icons attribute is set' do
pdf_theme = {
page_columns: 2,
page_column_gap: 12,
admonition_padding: 0,
admonition_column_rule_width: 0,
admonition_label_min_width: 24,
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
:icons: svg
:iconsdir: {imagesdir}
left column
[.column]
<<<
right column
[icon=square]
TIP: Use the icon attribute to customize the image for an admonition block.
EOS
expected_icon_x = (pdf.find_unique_text 'right column')[:x]
expected_content_x = expected_icon_x + 24
gs = pdf.extract_graphic_states pdf.pages[0][:raw_content]
(expect gs[0]).to include %(#{expected_icon_x} 574.33 200.0 200.0 re)
(expect (pdf.find_unique_text %r/Use /)[:x]).to eql expected_content_x
end
it 'should warn if SVG icon specified by icon attribute is missing' do
(expect do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }
:icons: font
[TIP,icon=missing]
Use the icon attribute to customize the image for an admonition block.
EOS
(expect get_images pdf, 1).to be_empty
(expect (pdf.page 1).text).to include 'TIP'
end).to log_message severity: :WARN, message: %(admonition icon image not found or not readable: #{fixture_file 'missing.png'})
end
it 'should warn if SVG icon specified by icon attribute has errors' do
(expect do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: :rect
:icons: font
:icontype: svg
[TIP,icon=faulty]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
(expect pdf.rectangles).to have_size 1
# NOTE: width and height of rectangle match what's defined in SVG
(expect pdf.rectangles[0][:width]).to eql 200.0
(expect pdf.rectangles[0][:height]).to eql 200.0
end).to log_message severity: :WARN, message: %(~problem encountered in image: #{fixture_file 'faulty.svg'}; Unknown tag 'foobar')
end
it 'should not warn if SVG icon specified by icon attribute in scratch document has errors' do
(expect do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: :rect
:icons: font
:icontype: svg
[%unbreakable]
--
[TIP,icon=faulty]
====
Use the icon attribute to customize the image for an admonition block.
====
--
EOS
(expect pdf.rectangles).to have_size 1
# NOTE: width and height of rectangle match what's defined in SVG
(expect pdf.rectangles[0][:width]).to eql 200.0
(expect pdf.rectangles[0][:height]).to eql 200.0
end).to log_message severity: :WARN, message: %(~problem encountered in image: #{fixture_file 'faulty.svg'}; Unknown tag 'foobar')
end
it 'should warn and fall back to admonition label if SVG icon cannot be found' do
(expect do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true
:icons:
:icontype: svg
[WARNING]
====
The admonition label will be used if the image cannot be resolved.
====
EOS
label_text = pdf.find_unique_text 'WARNING'
(expect label_text).not_to be_nil
(expect label_text[:font_name]).to include 'Bold'
end).to log_message severity: :WARN, message: %(admonition icon image for WARNING not found or not readable: #{fixture_file 'warning.svg'})
end
it 'should warn and fall back to admonition label if SVG icon specified by icon attribute cannot be embedded' do
(expect do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true
:icons: font
:icontype: svg
[TIP,icon=broken]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
label_text = pdf.find_unique_text 'TIP'
(expect label_text).not_to be_nil
(expect label_text[:font_name]).to include 'Bold'
end).to log_message severity: :WARN, message: %(~could not embed admonition icon image: #{fixture_file 'broken.svg'}; Missing end tag for 'rect')
end
it 'should resize fallback admonition label to fit in available space if icon fails to embed' do
(expect do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true
:icons: font
:icontype: svg
[WARNING,icon=broken]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
label_text = pdf.find_unique_text 'WARNING'
(expect label_text).not_to be_nil
(expect label_text[:font_size]).to be < 10.5
end).to log_message severity: :WARN, message: %(~could not embed admonition icon image: #{fixture_file 'broken.svg'}; Missing end tag for 'rect')
end
# NOTE: this test also verifies the text transform is applied as requested by theme
it 'should warn and fall back to admonition label if raster icon cannot be found' do
(expect do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, pdf_theme: { admonition_label_text_transform: 'uppercase' }, analyze: true
:icons:
[WARNING]
====
The admonition label will be used if the image cannot be resolved.
====
EOS
label_text = pdf.find_unique_text 'WARNING'
(expect label_text).not_to be_nil
(expect label_text[:font_name]).to include 'Bold'
end).to log_message severity: :WARN, message: %(admonition icon image for WARNING not found or not readable: #{fixture_file 'warning.png'})
end
# NOTE: this test also verifies the text transform is not applied if disabled by the theme
it 'should warn and fall back to admonition label if raster icon specified by icon attribute cannot be embedded' do
(expect do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, pdf_theme: { admonition_label_text_transform: 'none' }, analyze: true
:icons:
[TIP,icon=corrupt.png]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
label_text = pdf.find_unique_text 'Tip'
(expect label_text).not_to be_nil
(expect label_text[:font_name]).to include 'Bold'
end).to log_message severity: :WARN, message: %(~could not embed admonition icon image: #{fixture_file 'corrupt.png'}; image file is an unrecognised format)
end
it 'should embed remote image in icon if allow-uri-read attribute is set', network: true, visual: true do
to_file = to_pdf_file <<~'EOS', 'admonition-custom-svg-icon-with-remote-image.pdf', attribute_overrides: { 'docdir' => fixtures_dir, 'allow-uri-read' => '' }
:icons: font
:iconsdir:
[NOTE,icon=svg-with-remote-image.svg]
====
AsciiDoc is awesome!
====
EOS
(expect to_file).to visually_match 'admonition-custom-svg-icon-with-remote-image.pdf'
end
it 'should use original width of SVG icon if height is less than height of admonition block', visual: true do
to_file = to_pdf_file <<~'EOS', 'admonition-custom-svg-fit.pdf', attribute_overrides: { 'docdir' => fixtures_dir }
:icons: font
:iconsdir:
[NOTE,icon=green-bar.svg]
====
When you see this icon, it means there's additional advice about passing tests.
====
EOS
(expect to_file).to visually_match 'admonition-custom-svg-fit.pdf'
end
it 'should use raster icon specified by icon attribute when icons attribute is set', visual: true do
to_file = to_pdf_file <<~'EOS', 'admonition-custom-raster-icon.pdf', attribute_overrides: { 'docdir' => fixtures_dir }
:icons: font
:iconsdir:
[TIP,icon=tux.png]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
(expect to_file).to visually_match 'admonition-custom-raster-icon.pdf'
end
# NOTE: this is a pretty flimsy feature and probably needs some rethink
it 'should allow theme to control width of admonition icon image using admonition_label_min_width key' do
pdf_theme = { admonition_label_min_width: 40 }
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, attribute_overrides: { 'docdir' => fixtures_dir }, analyze: :image
:icons: font
:iconsdir:
[TIP,icon=logo.png]
====
Use the icon attribute to customize the image for an admonition block.
Use the admonition_label_min_width key to control the image width.
====
EOS
images = pdf.images
(expect images).to have_size 1
(expect images[0][:width]).to eql 40.0
end
it 'should resolve icon when icons attribute is set to image', visual: true do
to_file = to_pdf_file <<~'EOS', 'admonition-image-icon.pdf', attribute_overrides: { 'docdir' => fixtures_dir }
:icons: image
:iconsdir:
[TIP]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
(expect to_file).to visually_match 'admonition-custom-raster-icon.pdf'
end
it 'should not unset data-uri attribute when resolving icon image if already unset', visual: true do
doc = Asciidoctor.load <<~'EOS', backend: :pdf, safe: :safe, standalone: true, attributes: { 'docdir' => fixtures_dir, 'nofooter' => '' }
:icons: image
:iconsdir:
[TIP]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
(expect doc.converter).not_to be_nil
doc.remove_attr 'data-uri'
to_file = File.join output_dir, 'admonition-image-icon-no-data-uri.pdf'
doc.converter.write doc.convert, to_file
(expect to_file).to visually_match 'admonition-custom-raster-icon.pdf'
end
it 'should not resolve remote icon when icons attribute is set to image and allow-uri-read is not set' do
with_local_webserver do |base_url|
(expect do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => base_url }, analyze: true
:icons: image
[TIP]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
label_text = pdf.find_unique_text 'TIP'
(expect label_text).not_to be_nil
(expect pdf.lines).to eql ['TIP Use the icon attribute to customize the image for an admonition block.']
end).to log_messages [
{ severity: :WARN, message: %(cannot embed remote image: #{base_url}/tip.png (allow-uri-read attribute not enabled)) },
{ severity: :WARN, message: %(admonition icon image for TIP not found or not readable: #{base_url}/tip.png) },
]
end
end
it 'should not resolve remote icon when icons attribute is set to image, allow-uri-read is set, and image is missing' do
with_local_webserver do |base_url|
base_url += '/nada'
(expect do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'allow-uri-read' => '', 'iconsdir' => base_url }, analyze: true
:icons: image
[TIP]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
label_text = pdf.find_unique_text 'TIP'
(expect label_text).not_to be_nil
(expect pdf.lines).to eql ['TIP Use the icon attribute to customize the image for an admonition block.']
end).to log_messages [
{ severity: :WARN, message: %(could not retrieve remote image: #{base_url}/tip.png; 404 Not Found) },
{ severity: :WARN, message: %(admonition icon image for TIP not found or not readable: #{base_url}/tip.png) },
]
end
end
it 'should resolve remote icon when icons attribute is set to image and allow-uri-read is set', visual: true do
to_file = with_local_webserver do |base_url|
to_pdf_file <<~'EOS', 'admonition-remote-image-icon.pdf', attribute_overrides: { 'allow-uri-read' => '', 'iconsdir' => base_url }
:icons: image
[TIP]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
end
(expect to_file).to visually_match 'admonition-custom-raster-icon.pdf'
end
it 'should resize icon only if it does not fit within the available space' do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'docdir' => fixtures_dir }, analyze: :image
:icons: image
:iconsdir:
[TIP]
This is Tux.
He's the Linux mascot.
EOS
images = pdf.images
(expect images).to have_size 1
(expect images[0][:width]).to be < 36.0
(expect images[0][:height]).to be < 42.3529
pdf = to_pdf <<~'EOS', attribute_overrides: { 'docdir' => fixtures_dir }, analyze: :image
:icons: image
:iconsdir:
[TIP]
====
This is Tux.
If you spend any amount of time in the Linux world, you'll see him a lot.
He's the Linux mascot.
Thanks to Linux, penguins have receive a lot more attention.
Technology can sometimes be a force for good like that.
====
EOS
images = pdf.images
(expect images).to have_size 1
(expect images[0][:width]).to eql 36.0
(expect images[0][:height]).to eql 42.35294
end
it 'should warn and fall back to admonition label if image icon cannot be resolved' do
(expect do
pdf = to_pdf <<~'EOS', attribute_overrides: { 'docdir' => fixtures_dir }, analyze: true
:icons: image
:iconsdir:
[NOTE]
====
Use the icon attribute to customize the image for an admonition block.
====
EOS
note_text = pdf.find_unique_text 'NOTE'
(expect note_text).not_to be_nil
(expect note_text[:font_name]).to include 'Bold'
end).to log_message severity: :WARN, message: '~admonition icon image for NOTE not found or not readable'
end
it 'should use icon image specified in theme if icon attribute is not set on block', visual: true do
to_file = to_pdf_file <<~'EOS', 'admonition-icon-image.pdf', attribute_overrides: { 'pdf-theme' => (fixture_file 'admonition-image-theme.yml') }, analyze: true
:icons:
[NOTE]
====
You can use a custom PDF theme to customize the icon image for a specific admonition type.
====
EOS
(expect to_file).to visually_match 'admonition-icon-image.pdf'
end
it 'should substitute attribute references in icon image value in theme', visual: true do
pdf_theme = { admonition_icon_note: { image: '{docdir}/tux-note.svg' } }
to_file = to_pdf_file <<~'EOS', 'admonition-icon-image-with-attribute-ref.pdf', attribute_overrides: { 'docdir' => fixtures_dir }, pdf_theme: pdf_theme, analyze: true
:icons:
[NOTE]
====
You can use a custom PDF theme to customize the icon image for a specific admonition type.
====
EOS
(expect to_file).to visually_match 'admonition-icon-image.pdf'
end
it 'should warn and fall back to admonition label if icon image specified in theme cannot be resolved' do
pdf_theme = {
__dir__: fixtures_dir,
admonition_icon_note: { image: 'does-not-exist.png' },
}
(expect do
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme
:icons:
[NOTE]
====
If the icon image cannot be found, the converter will fall back to using the label text in the place of the icon.
====
EOS
(expect get_images pdf).to be_empty
(expect pdf.pages[0].text).to include 'NOTE'
end).to log_message severity: :WARN, message: '~admonition icon image for NOTE not found or not readable'
end
it 'should allow theme to specify icon for custom admonition type' do
require 'asciidoctor/extensions'
extensions = proc do
block :QUESTION do
on_context :example
process do |parent, reader, attrs|
attrs['name'] = 'question'
attrs['caption'] = 'Question'
create_block parent, :admonition, reader.lines, attrs, content_model: :compound
end
end
end
pdf_theme = {
admonition_icon_question: { name: 'question-circle' },
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, extensions: extensions, analyze: true
:icons: font
[QUESTION]
====
Are you following along?
Just checking ;)
====
EOS
icon_text = pdf.find_unique_text ?\uf059
(expect icon_text).not_to be_nil
(expect icon_text[:font_name]).to eql 'FontAwesome5Free-Solid'
(expect icon_text[:font_size]).to be 24
(expect pdf.find_unique_text 'Are you following along?').not_to be_nil
(expect pdf.find_unique_text 'Just checking ;)').not_to be_nil
end
it 'should use note icon for custom admonition type if theme does not specify icon name' do
require 'asciidoctor/extensions'
extensions = proc do
block :FACT do
on_context :example
process do |parent, reader, attrs|
attrs['name'] = 'fact'
attrs['caption'] = 'Fact'
create_block parent, :admonition, reader.lines, attrs, content_model: :compound
end
end
end
pdf = to_pdf <<~'EOS', extensions: extensions, analyze: true
:icons: font
[FACT]
====
Like all planetary bodies, the Earth is spherical.
====
EOS
(expect pdf.lines).to eql [%(\uf05a Like all planetary bodies, the Earth is spherical.)]
icon_text = pdf.find_unique_text ?\uf05a
(expect icon_text[:font_color]).to eql '333333'
end
end
context 'Background & Lines' do
it 'should allow theme to customize color, width, and style of column rule' do
%w(dotted dashed).each do |style|
pdf_theme = {
admonition_column_rule_color: '222222',
admonition_column_rule_width: 1,
admonition_column_rule_style: style,
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line
TIP: You can use the theme to customize the color and width of the column rule.
EOS
lines = pdf.lines
(expect lines).to have_size 1
column_rule = lines[0]
(expect column_rule[:from][:x]).to eql column_rule[:to][:x]
(expect column_rule[:color]).to eql '222222'
(expect column_rule[:width]).to eql 1
(expect column_rule[:style]).to eql style.to_sym
end
end
it 'should not draw column rule if value is transparent' do
pdf_theme = { admonition_column_rule_color: 'transparent' }
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line
TIP: You can use the theme to customize the color and width of the column rule.
EOS
lines = pdf.lines
(expect lines).to be_empty
end
it 'should not draw column rule if value is nil and base border color is transparent' do
pdf_theme = { base_border_color: 'transparent', admonition_column_rule_color: nil }
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line
TIP: You can use the theme to customize the color and width of the column rule.
EOS
lines = pdf.lines
(expect lines).to be_empty
end
it 'should not assign default width to column rule if key is not specified' do
pdf_theme = {
admonition_column_rule_color: '222222',
admonition_column_rule_width: nil,
base_border_width: nil,
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line
TIP: You can use the theme to customize the color and width of the column rule.
EOS
lines = pdf.lines
(expect lines).to be_empty
end
it 'should not fail if base border width is not set when using original theme' do
pdf_theme = {
extends: 'base',
base_border_width: nil,
admonition_column_rule_width: nil,
admonition_column_rule_color: '222222',
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line
TIP: You can use the theme to customize the color and width of the column rule.
EOS
(expect pdf.lines).to be_empty
end
it 'should allow theme to specify double style for column rule' do
pdf_theme = {
admonition_column_rule_color: '222222',
admonition_column_rule_width: 1,
admonition_column_rule_style: 'double',
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line
TIP: You can use the theme to customize the color and width of the column rule.
EOS
lines = pdf.lines
(expect lines).to have_size 2
column_rule1 = lines[0]
(expect column_rule1[:from][:x]).to eql column_rule1[:to][:x]
(expect column_rule1[:color]).to eql '222222'
(expect column_rule1[:width]).to eql 1
(expect column_rule1[:style]).to eql :solid
column_rule2 = lines[1]
(expect column_rule2[:from][:x]).to eql column_rule2[:to][:x]
(expect column_rule2[:color]).to eql '222222'
(expect column_rule2[:width]).to eql 1
(expect column_rule2[:style]).to eql :solid
(expect column_rule2[:from][:x] - column_rule1[:from][:x]).to eql 2.0
end
it 'should not use base border width for column rule if column rule width is nil' do
pdf_theme = {
base_border_width: 2,
admonition_column_rule_color: '222222',
admonition_column_rule_width: nil,
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line
TIP: You can use the theme to customize the color and width of the column rule.
EOS
lines = pdf.lines
(expect lines).to be_empty
end
it 'should allow theme to add border', visual: true do
pdf_theme = {
admonition_border_width: 0.5,
admonition_border_radius: 5,
admonition_border_color: 'e0e0e0',
admonition_column_rule_color: 'e0e0e0',
}
to_file = to_pdf_file <<~'EOS', 'admonition-border.pdf', pdf_theme: pdf_theme
TIP: You can use the theme to add a border.
EOS
(expect to_file).to visually_match 'admonition-border.pdf'
end
it 'should allow theme to add background color', visual: true do
pdf_theme = {
admonition_background_color: 'eeeeee',
admonition_border_radius: 3,
admonition_column_rule_width: 0,
}
to_file = to_pdf_file <<~'EOS', 'admonition-background-color.pdf', pdf_theme: pdf_theme
TIP: You can use the theme to add a background color.
EOS
(expect to_file).to visually_match 'admonition-background-color.pdf'
end
it 'should apply correct padding around content' do
pdf_theme = { admonition_background_color: 'EEEEEE' }
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
:icons: font
[NOTE]
====
first
last
====
EOS
boundaries = (pdf.extract_graphic_states pdf.pages[0][:raw_content])[0]
.select {|l| l.end_with? 'l' }
.map {|l| l.split.yield_self {|it| { x: it[0].to_f, y: it[1].to_f } } }
(expect boundaries).to have_size 4
top, bottom = boundaries.map {|it| it[:y] }.yield_self {|it| [it.max, it.min] }
left = boundaries.map {|it| it[:x] }.min
text_top = (pdf.find_unique_text 'first').yield_self {|it| it[:y] + it[:font_size] }
text_bottom = (pdf.find_unique_text 'last')[:y]
text_left = (pdf.find_unique_text 'first')[:x]
(expect (top - text_top).to_f).to (be_within 2).of 4.0
(expect (text_bottom - bottom).to_f).to (be_within 2).of 8.0 # extra padding is descender
(expect (text_left - left).to_f).to eql 72.0
end
it 'should apply correct padding around content when using base theme' do
pdf_theme = { extends: 'base', admonition_background_color: 'EEEEEE' }
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
:icons: font
[NOTE]
====
first
last
====
EOS
boundaries = (pdf.extract_graphic_states pdf.pages[0][:raw_content])[0]
.select {|l| l.end_with? 'l' }
.map {|l| l.split.yield_self {|it| { x: it[0].to_f, y: it[1].to_f } } }
(expect boundaries).to have_size 4
top, bottom = boundaries.map {|it| it[:y] }.yield_self {|it| [it.max, it.min] }
left = boundaries.map {|it| it[:x] }.min
text_top = (pdf.find_unique_text 'first').yield_self {|it| it[:y] + it[:font_size] }
text_bottom = (pdf.find_unique_text 'last')[:y]
text_left = (pdf.find_unique_text 'first')[:x]
(expect (top - text_top).to_f).to (be_within 1).of 4.0
(expect (text_bottom - bottom).to_f).to (be_within 1).of 8.0 # extra padding is descender
(expect (text_left - left).to_f).to eql 72.0
end
it 'should allow theme to disable column rule by setting width to 0' do
pdf_theme = { admonition_column_rule_width: 0 }
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line
TIP: You can use the theme to add a background color.
EOS
(expect pdf.lines).to be_empty
end
end
end
|