prawn 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -5
  3. data/lib/prawn.rb +4 -4
  4. data/lib/prawn/document.rb +47 -46
  5. data/lib/prawn/document/bounding_box.rb +13 -19
  6. data/lib/prawn/document/column_box.rb +3 -5
  7. data/lib/prawn/document/internals.rb +0 -1
  8. data/lib/prawn/document/span.rb +12 -12
  9. data/lib/prawn/errors.rb +32 -33
  10. data/lib/prawn/font.rb +29 -36
  11. data/lib/prawn/font/afm.rb +20 -20
  12. data/lib/prawn/font/dfont.rb +0 -1
  13. data/lib/prawn/font/ttf.rb +30 -27
  14. data/lib/prawn/font_metric_cache.rb +4 -8
  15. data/lib/prawn/graphics.rb +37 -42
  16. data/lib/prawn/graphics/cap_style.rb +1 -1
  17. data/lib/prawn/graphics/color.rb +21 -23
  18. data/lib/prawn/graphics/dash.rb +5 -6
  19. data/lib/prawn/graphics/join_style.rb +1 -2
  20. data/lib/prawn/graphics/patterns.rb +25 -21
  21. data/lib/prawn/graphics/transformation.rb +4 -5
  22. data/lib/prawn/graphics/transparency.rb +6 -8
  23. data/lib/prawn/grid.rb +21 -14
  24. data/lib/prawn/image_handler.rb +2 -2
  25. data/lib/prawn/images.rb +29 -31
  26. data/lib/prawn/images/image.rb +1 -1
  27. data/lib/prawn/images/jpg.rb +10 -12
  28. data/lib/prawn/images/png.rb +13 -13
  29. data/lib/prawn/measurements.rb +7 -14
  30. data/lib/prawn/outline.rb +6 -6
  31. data/lib/prawn/repeater.rb +1 -5
  32. data/lib/prawn/security.rb +17 -25
  33. data/lib/prawn/security/arcfour.rb +1 -1
  34. data/lib/prawn/soft_mask.rb +11 -12
  35. data/lib/prawn/stamp.rb +16 -8
  36. data/lib/prawn/text.rb +23 -20
  37. data/lib/prawn/text/box.rb +3 -6
  38. data/lib/prawn/text/formatted/arranger.rb +9 -12
  39. data/lib/prawn/text/formatted/box.rb +23 -22
  40. data/lib/prawn/text/formatted/fragment.rb +0 -4
  41. data/lib/prawn/text/formatted/line_wrap.rb +13 -24
  42. data/lib/prawn/text/formatted/parser.rb +16 -20
  43. data/lib/prawn/text/formatted/wrap.rb +2 -7
  44. data/lib/prawn/utilities.rb +6 -3
  45. data/lib/prawn/version.rb +1 -1
  46. data/manual/basic_concepts/basic_concepts.rb +0 -2
  47. data/manual/basic_concepts/view.rb +1 -1
  48. data/manual/bounding_box/bounding_box.rb +0 -3
  49. data/manual/bounding_box/russian_boxes.rb +7 -8
  50. data/manual/bounding_box/stretchy.rb +0 -1
  51. data/manual/contents.rb +2 -2
  52. data/manual/cover.rb +11 -12
  53. data/manual/document_and_page_options/document_and_page_options.rb +2 -5
  54. data/manual/document_and_page_options/metadata.rb +10 -10
  55. data/manual/document_and_page_options/page_size.rb +0 -1
  56. data/manual/graphics/fill_rules.rb +5 -4
  57. data/manual/graphics/graphics.rb +0 -3
  58. data/manual/graphics/lines_and_curves.rb +1 -1
  59. data/manual/graphics/rotate.rb +0 -2
  60. data/manual/graphics/scale.rb +4 -2
  61. data/manual/graphics/soft_masks.rb +0 -1
  62. data/manual/graphics/stroke_cap.rb +1 -1
  63. data/manual/graphics/stroke_join.rb +1 -1
  64. data/manual/graphics/translate.rb +3 -3
  65. data/manual/graphics/transparency.rb +0 -1
  66. data/manual/how_to_read_this_manual.rb +0 -1
  67. data/manual/images/images.rb +0 -3
  68. data/manual/layout/boxes.rb +5 -5
  69. data/manual/layout/content.rb +2 -2
  70. data/manual/layout/layout.rb +0 -3
  71. data/manual/outline/outline.rb +0 -3
  72. data/manual/repeatable_content/page_numbering.rb +1 -1
  73. data/manual/repeatable_content/repeatable_content.rb +0 -3
  74. data/manual/repeatable_content/repeater.rb +6 -6
  75. data/manual/security/encryption.rb +0 -2
  76. data/manual/security/permissions.rb +0 -2
  77. data/manual/security/security.rb +0 -3
  78. data/manual/text/alignment.rb +3 -3
  79. data/manual/text/color.rb +0 -1
  80. data/manual/text/column_box.rb +0 -1
  81. data/manual/text/fallback_fonts.rb +2 -2
  82. data/manual/text/formatted_callbacks.rb +3 -2
  83. data/manual/text/paragraph_indentation.rb +2 -3
  84. data/manual/text/registering_families.rb +13 -9
  85. data/manual/text/rotation.rb +0 -1
  86. data/manual/text/text.rb +0 -3
  87. data/manual/text/text_box_overflow.rb +7 -5
  88. data/manual/text/utf8.rb +1 -1
  89. data/manual/text/win_ansi_charset.rb +2 -2
  90. data/prawn.gemspec +4 -4
  91. data/spec/acceptance/png.rb +6 -7
  92. data/spec/annotations_spec.rb +21 -28
  93. data/spec/bounding_box_spec.rb +100 -109
  94. data/spec/column_box_spec.rb +26 -32
  95. data/spec/destinations_spec.rb +2 -4
  96. data/spec/document_spec.rb +145 -151
  97. data/spec/extensions/mocha.rb +0 -1
  98. data/spec/font_metric_cache_spec.rb +7 -7
  99. data/spec/font_spec.rb +103 -102
  100. data/spec/formatted_text_arranger_spec.rb +76 -74
  101. data/spec/formatted_text_box_spec.rb +170 -159
  102. data/spec/formatted_text_fragment_spec.rb +57 -56
  103. data/spec/graphics_spec.rb +158 -175
  104. data/spec/grid_spec.rb +28 -29
  105. data/spec/image_handler_spec.rb +4 -5
  106. data/spec/images_spec.rb +50 -36
  107. data/spec/inline_formatted_text_parser_spec.rb +397 -393
  108. data/spec/jpg_spec.rb +4 -6
  109. data/spec/line_wrap_spec.rb +54 -55
  110. data/spec/measurement_units_spec.rb +12 -15
  111. data/spec/outline_spec.rb +77 -98
  112. data/spec/png_spec.rb +55 -65
  113. data/spec/reference_spec.rb +3 -3
  114. data/spec/repeater_spec.rb +20 -26
  115. data/spec/security_spec.rb +42 -49
  116. data/spec/soft_mask_spec.rb +4 -5
  117. data/spec/span_spec.rb +5 -6
  118. data/spec/spec_helper.rb +2 -4
  119. data/spec/stamp_spec.rb +41 -22
  120. data/spec/stroke_styles_spec.rb +36 -39
  121. data/spec/text_at_spec.rb +28 -29
  122. data/spec/text_box_spec.rb +160 -165
  123. data/spec/text_rendering_mode_spec.rb +9 -9
  124. data/spec/text_spacing_spec.rb +13 -13
  125. data/spec/text_spec.rb +116 -124
  126. data/spec/text_with_inline_formatting_spec.rb +5 -5
  127. data/spec/transparency_spec.rb +20 -20
  128. data/spec/view_spec.rb +0 -1
  129. metadata +7 -7
@@ -11,22 +11,22 @@ describe "Core::Text::Formatted::Arranger#format_array" do
11
11
  { :text => "are", :styles => [:bold, :italic] },
12
12
  { :text => " you?" }]
13
13
  arranger.format_array = array
14
- arranger.unconsumed[0].should == { :text => "hello " }
15
- arranger.unconsumed[1].should == { :text => "world how ",
16
- :styles => [:bold] }
17
- arranger.unconsumed[2].should == { :text => "are",
18
- :styles => [:bold, :italic] }
19
- arranger.unconsumed[3].should == { :text => " you?" }
14
+ expect(arranger.unconsumed[0]).to eq(:text => "hello ")
15
+ expect(arranger.unconsumed[1]).to eq(:text => "world how ",
16
+ :styles => [:bold])
17
+ expect(arranger.unconsumed[2]).to eq(:text => "are",
18
+ :styles => [:bold, :italic])
19
+ expect(arranger.unconsumed[3]).to eq(:text => " you?")
20
20
  end
21
21
  it "should split newlines into their own elements" do
22
22
  create_pdf
23
23
  arranger = Prawn::Text::Formatted::Arranger.new(@pdf)
24
24
  array = [{ :text => "\nhello\nworld" }]
25
25
  arranger.format_array = array
26
- arranger.unconsumed[0].should == { :text => "\n" }
27
- arranger.unconsumed[1].should == { :text => "hello" }
28
- arranger.unconsumed[2].should == { :text => "\n" }
29
- arranger.unconsumed[3].should == { :text => "world" }
26
+ expect(arranger.unconsumed[0]).to eq(:text => "\n")
27
+ expect(arranger.unconsumed[1]).to eq(:text => "hello")
28
+ expect(arranger.unconsumed[2]).to eq(:text => "\n")
29
+ expect(arranger.unconsumed[3]).to eq(:text => "world")
30
30
  end
31
31
  end
32
32
  describe "Core::Text::Formatted::Arranger#preview_next_string" do
@@ -36,14 +36,14 @@ describe "Core::Text::Formatted::Arranger#preview_next_string" do
36
36
  array = [{ :text => "hello" }]
37
37
  arranger.format_array = array
38
38
  arranger.preview_next_string
39
- arranger.consumed.should == []
39
+ expect(arranger.consumed).to eq([])
40
40
  end
41
41
  it "should not consumed array" do
42
42
  create_pdf
43
43
  arranger = Prawn::Text::Formatted::Arranger.new(@pdf)
44
44
  array = [{ :text => "hello" }]
45
45
  arranger.format_array = array
46
- arranger.preview_next_string.should == "hello"
46
+ expect(arranger.preview_next_string).to eq("hello")
47
47
  end
48
48
  end
49
49
  describe "Core::Text::Formatted::Arranger#next_string" do
@@ -56,22 +56,22 @@ describe "Core::Text::Formatted::Arranger#next_string" do
56
56
  { :text => " you?" }]
57
57
  @arranger.format_array = array
58
58
  end
59
- it "should raise_error an error if called after a line was finalized and" +
59
+ it "should raise_error an error if called after a line was finalized and" \
60
60
  " before a new line was initialized" do
61
61
  @arranger.finalize_line
62
- lambda do
62
+ expect do
63
63
  @arranger.next_string
64
- end.should raise_error(RuntimeError)
64
+ end.to raise_error(RuntimeError)
65
65
  end
66
66
  it "should populate consumed array" do
67
67
  while string = @arranger.next_string
68
68
  end
69
- @arranger.consumed[0].should == { :text => "hello " }
70
- @arranger.consumed[1].should == { :text => "world how ",
71
- :styles => [:bold] }
72
- @arranger.consumed[2].should == { :text => "are",
73
- :styles => [:bold, :italic] }
74
- @arranger.consumed[3].should == { :text => " you?" }
69
+ expect(@arranger.consumed[0]).to eq(:text => "hello ")
70
+ expect(@arranger.consumed[1]).to eq(:text => "world how ",
71
+ :styles => [:bold])
72
+ expect(@arranger.consumed[2]).to eq(:text => "are",
73
+ :styles => [:bold, :italic])
74
+ expect(@arranger.consumed[3]).to eq(:text => " you?")
75
75
  end
76
76
  it "should populate current_format_state array" do
77
77
  create_pdf
@@ -85,13 +85,13 @@ describe "Core::Text::Formatted::Arranger#next_string" do
85
85
  while string = arranger.next_string
86
86
  case counter
87
87
  when 0
88
- arranger.current_format_state.should == { }
88
+ expect(arranger.current_format_state).to eq({})
89
89
  when 1
90
- arranger.current_format_state.should == { :styles => [:bold] }
90
+ expect(arranger.current_format_state).to eq(:styles => [:bold])
91
91
  when 2
92
- arranger.current_format_state.should == { :styles => [:bold, :italic] }
92
+ expect(arranger.current_format_state).to eq(:styles => [:bold, :italic])
93
93
  when 3
94
- arranger.current_format_state.should == { }
94
+ expect(arranger.current_format_state).to eq({})
95
95
  end
96
96
  counter += 1
97
97
  end
@@ -109,11 +109,11 @@ describe "Core::Text::Formatted::Arranger#retrieve_fragment" do
109
109
  arranger.format_array = array
110
110
  while string = arranger.next_string
111
111
  end
112
- lambda do
112
+ expect do
113
113
  arranger.retrieve_fragment
114
- end.should raise_error(RuntimeError)
114
+ end.to raise_error(RuntimeError)
115
115
  end
116
- it "should return the consumed fragments in order of consumption" +
116
+ it "should return the consumed fragments in order of consumption" \
117
117
  " and update" do
118
118
  create_pdf
119
119
  arranger = Prawn::Text::Formatted::Arranger.new(@pdf)
@@ -125,10 +125,10 @@ describe "Core::Text::Formatted::Arranger#retrieve_fragment" do
125
125
  while string = arranger.next_string
126
126
  end
127
127
  arranger.finalize_line
128
- arranger.retrieve_fragment.text.should == "hello "
129
- arranger.retrieve_fragment.text.should == "world how "
130
- arranger.retrieve_fragment.text.should == "are"
131
- arranger.retrieve_fragment.text.should == " you?"
128
+ expect(arranger.retrieve_fragment.text).to eq("hello ")
129
+ expect(arranger.retrieve_fragment.text).to eq("world how ")
130
+ expect(arranger.retrieve_fragment.text).to eq("are")
131
+ expect(arranger.retrieve_fragment.text).to eq(" you?")
132
132
  end
133
133
  it "should never return a fragment whose text is an empty string" do
134
134
  create_pdf
@@ -147,7 +147,7 @@ describe "Core::Text::Formatted::Arranger#retrieve_fragment" do
147
147
  end
148
148
  arranger.finalize_line
149
149
  while fragment = arranger.retrieve_fragment
150
- fragment.text.should_not be_empty
150
+ expect(fragment.text).not_to be_empty
151
151
  end
152
152
  end
153
153
  it "should not alter the current font style" do
@@ -162,12 +162,12 @@ describe "Core::Text::Formatted::Arranger#retrieve_fragment" do
162
162
  end
163
163
  arranger.finalize_line
164
164
  arranger.retrieve_fragment
165
- arranger.current_format_state[:styles].should be_nil
165
+ expect(arranger.current_format_state[:styles]).to be_nil
166
166
  end
167
167
  end
168
168
 
169
169
  describe "Core::Text::Formatted::Arranger#update_last_string" do
170
- it "should update the last retrieved string with what actually fit on" +
170
+ it "should update the last retrieved string with what actually fit on" \
171
171
  "the line and the list of unconsumed with what did not" do
172
172
  create_pdf
173
173
  arranger = Prawn::Text::Formatted::Arranger.new(@pdf)
@@ -179,10 +179,10 @@ describe "Core::Text::Formatted::Arranger#update_last_string" do
179
179
  while string = arranger.next_string
180
180
  end
181
181
  arranger.update_last_string(" you", " now?", nil)
182
- arranger.consumed[3].should == { :text => " you",
183
- :styles => [:bold, :italic] }
184
- arranger.unconsumed.should == [{ :text => " now?",
185
- :styles => [:bold, :italic] }]
182
+ expect(arranger.consumed[3]).to eq(:text => " you",
183
+ :styles => [:bold, :italic])
184
+ expect(arranger.unconsumed).to eq([{ :text => " now?",
185
+ :styles => [:bold, :italic] }])
186
186
  end
187
187
  it "should set the format state to the previously processed fragment" do
188
188
  create_pdf
@@ -193,24 +193,26 @@ describe "Core::Text::Formatted::Arranger#update_last_string" do
193
193
  { :text => " you now?" }]
194
194
  arranger.format_array = array
195
195
  3.times { arranger.next_string }
196
- arranger.current_format_state.should == { :styles => [:bold, :italic] }
196
+ expect(arranger.current_format_state).to eq(:styles => [:bold, :italic])
197
197
  arranger.update_last_string("", "are", "-")
198
- arranger.current_format_state.should == { :styles => [:bold] }
198
+ expect(arranger.current_format_state).to eq(:styles => [:bold])
199
199
  end
200
200
 
201
201
  context "when the entire string was used" do
202
202
  it "should not push empty string onto unconsumed" do
203
- create_pdf
204
- arranger = Prawn::Text::Formatted::Arranger.new(@pdf)
205
- array = [{ :text => "hello " },
206
- { :text => "world how ", :styles => [:bold] },
207
- { :text => "are", :styles => [:bold, :italic] },
208
- { :text => " you now?" }]
209
- arranger.format_array = array
203
+ create_pdf
204
+ arranger = Prawn::Text::Formatted::Arranger.new(@pdf)
205
+ array = [
206
+ { :text => "hello " },
207
+ { :text => "world how ", :styles => [:bold] },
208
+ { :text => "are", :styles => [:bold, :italic] },
209
+ { :text => " you now?" }
210
+ ]
211
+ arranger.format_array = array
210
212
  while string = arranger.next_string
211
213
  end
212
214
  arranger.update_last_string(" you now?", "", nil)
213
- arranger.unconsumed.should == []
215
+ expect(arranger.unconsumed).to eq([])
214
216
  end
215
217
  end
216
218
  end
@@ -227,17 +229,17 @@ describe "Core::Text::Formatted::Arranger#space_count" do
227
229
  end
228
230
  end
229
231
  it "should raise_error an error if called before finalize_line was called" do
230
- lambda do
232
+ expect do
231
233
  @arranger.space_count
232
- end.should raise_error(RuntimeError)
234
+ end.to raise_error(RuntimeError)
233
235
  end
234
236
  it "should return the total number of spaces in all fragments" do
235
237
  @arranger.finalize_line
236
- @arranger.space_count.should == 4
238
+ expect(@arranger.space_count).to eq(4)
237
239
  end
238
240
  end
239
241
  describe "Core::Text::Formatted::Arranger#finalize_line" do
240
- it "should make it so that all trailing white space fragments " +
242
+ it "should make it so that all trailing white space fragments " \
241
243
  "exclude trailing white space" do
242
244
  create_pdf
243
245
  arranger = Prawn::Text::Formatted::Arranger.new(@pdf)
@@ -248,16 +250,16 @@ describe "Core::Text::Formatted::Arranger#finalize_line" do
248
250
  while string = arranger.next_string
249
251
  end
250
252
  arranger.finalize_line
251
- arranger.fragments.length.should == 3
253
+ expect(arranger.fragments.length).to eq(3)
252
254
 
253
255
  fragment = arranger.retrieve_fragment
254
- fragment.text.should == "hello "
256
+ expect(fragment.text).to eq("hello ")
255
257
 
256
258
  fragment = arranger.retrieve_fragment
257
- fragment.text.should == "world how"
259
+ expect(fragment.text).to eq("world how")
258
260
 
259
261
  fragment = arranger.retrieve_fragment
260
- fragment.text.should == ""
262
+ expect(fragment.text).to eq("")
261
263
  end
262
264
  end
263
265
 
@@ -272,13 +274,13 @@ describe "Core::Text::Formatted::Arranger#line_width" do
272
274
  end
273
275
  end
274
276
  it "should raise_error an error if called before finalize_line was called" do
275
- lambda do
277
+ expect do
276
278
  @arranger.line_width
277
- end.should raise_error(RuntimeError)
279
+ end.to raise_error(RuntimeError)
278
280
  end
279
281
  it "should return the width of the complete line" do
280
282
  @arranger.finalize_line
281
- @arranger.line_width.should be > 0
283
+ expect(@arranger.line_width).to be > 0
282
284
  end
283
285
  end
284
286
 
@@ -296,15 +298,14 @@ describe "Core::Text::Formatted::Arranger#line_width with character_spacing > 0"
296
298
 
297
299
  base_line_width = arranger.line_width
298
300
 
299
-
300
301
  array = [{ :text => "hello " },
301
302
  { :text => "world", :styles => [:bold],
302
- :character_spacing => 7}]
303
+ :character_spacing => 7 }]
303
304
  arranger.format_array = array
304
305
  while string = arranger.next_string
305
306
  end
306
307
  arranger.finalize_line
307
- arranger.line_width.should be > base_line_width
308
+ expect(arranger.line_width).to be > base_line_width
308
309
  end
309
310
  end
310
311
 
@@ -319,13 +320,13 @@ describe "Core::Text::Formatted::Arranger#line" do
319
320
  end
320
321
  end
321
322
  it "should raise_error an error if called before finalize_line was called" do
322
- lambda do
323
+ expect do
323
324
  @arranger.line
324
- end.should raise_error(RuntimeError)
325
+ end.to raise_error(RuntimeError)
325
326
  end
326
327
  it "should return the complete line" do
327
328
  @arranger.finalize_line
328
- @arranger.line.should == "hello world"
329
+ expect(@arranger.line).to eq("hello world")
329
330
  end
330
331
  end
331
332
 
@@ -338,7 +339,7 @@ describe "Core::Text::Formatted::Arranger#unconsumed" do
338
339
  { :text => "are", :styles => [:bold, :italic] },
339
340
  { :text => " you now?" }]
340
341
  arranger.format_array = array
341
- arranger.unconsumed.should == array
342
+ expect(arranger.unconsumed).to eq(array)
342
343
  end
343
344
  it "should return an empty array if everything was consumed" do
344
345
  create_pdf
@@ -350,7 +351,7 @@ describe "Core::Text::Formatted::Arranger#unconsumed" do
350
351
  arranger.format_array = array
351
352
  while string = arranger.next_string
352
353
  end
353
- arranger.unconsumed.should == []
354
+ expect(arranger.unconsumed).to eq([])
354
355
  end
355
356
  end
356
357
 
@@ -366,7 +367,7 @@ describe "Core::Text::Formatted::Arranger#finished" do
366
367
  while string = arranger.next_string
367
368
  end
368
369
  arranger.update_last_string(" you", "now?", nil)
369
- arranger.should_not be_finished
370
+ expect(arranger).not_to be_finished
370
371
  end
371
372
  it "should be_false if everything was printed" do
372
373
  create_pdf
@@ -378,7 +379,7 @@ describe "Core::Text::Formatted::Arranger#finished" do
378
379
  arranger.format_array = array
379
380
  while string = arranger.next_string
380
381
  end
381
- arranger.should be_finished
382
+ expect(arranger).to be_finished
382
383
  end
383
384
  end
384
385
 
@@ -395,7 +396,7 @@ describe "Core::Text::Formatted::Arranger.max_line_height" do
395
396
  while string = arranger.next_string
396
397
  end
397
398
  arranger.finalize_line
398
- arranger.max_line_height.should be_within(0.0001).of(33.32)
399
+ expect(arranger.max_line_height).to be_within(0.0001).of(33.32)
399
400
  end
400
401
  end
401
402
 
@@ -414,8 +415,9 @@ describe "Core::Text::Formatted::Arranger#repack_unretrieved" do
414
415
  arranger.retrieve_fragment
415
416
  arranger.retrieve_fragment
416
417
  arranger.repack_unretrieved
417
- arranger.unconsumed.should == [
418
- { :text => "are", :styles => [:bold, :italic] },
419
- { :text => " you now?" }]
418
+ expect(arranger.unconsumed).to eq([
419
+ { :text => "are", :styles => [:bold, :italic] },
420
+ { :text => " you now?" }
421
+ ])
420
422
  end
421
423
  end
@@ -9,13 +9,13 @@ describe "Text::Formatted::Box wrapping" do
9
9
 
10
10
  it "should not wrap between two fragments" do
11
11
  texts = [
12
- {:text => "Hello "},
13
- {:text => "World"},
14
- {:text => "2", :styles => [:superscript]},
15
- ]
12
+ { :text => "Hello " },
13
+ { :text => "World" },
14
+ { :text => "2", :styles => [:superscript] }
15
+ ]
16
16
  text_box = Prawn::Text::Formatted::Box.new(texts, :document => @pdf, :width => @pdf.width_of("Hello World"))
17
17
  text_box.render
18
- text_box.text.should == "Hello\nWorld2"
18
+ expect(text_box.text).to eq("Hello\nWorld2")
19
19
  end
20
20
 
21
21
  it "should not raise an Encoding::CompatibilityError when keeping a TTF and an AFM font together" do
@@ -25,9 +25,11 @@ describe "Text::Formatted::Box wrapping" do
25
25
  :normal => { :file => file, :font => "Kai" }
26
26
  }
27
27
 
28
- texts = [{ :text => "Hello " },
29
- { :text => "再见", :font => "Kai"},
30
- { :text => "World" }]
28
+ texts = [
29
+ { :text => "Hello " },
30
+ { :text => "再见", :font => "Kai" },
31
+ { :text => "World" }
32
+ ]
31
33
  text_box = Prawn::Text::Formatted::Box.new(texts, :document => @pdf, :width => @pdf.width_of("Hello World"))
32
34
 
33
35
  text_box.render
@@ -35,55 +37,55 @@ describe "Text::Formatted::Box wrapping" do
35
37
 
36
38
  it "should wrap between two fragments when the preceding fragment ends with white space" do
37
39
  texts = [
38
- {:text => "Hello "},
39
- {:text => "World "},
40
- {:text => "2", :styles => [:superscript]},
41
- ]
40
+ { :text => "Hello " },
41
+ { :text => "World " },
42
+ { :text => "2", :styles => [:superscript] }
43
+ ]
42
44
  text_box = Prawn::Text::Formatted::Box.new(texts, :document => @pdf, :width => @pdf.width_of("Hello World"))
43
45
  text_box.render
44
- text_box.text.should == "Hello World\n2"
46
+ expect(text_box.text).to eq("Hello World\n2")
45
47
 
46
48
  texts = [
47
- {:text => "Hello "},
48
- {:text => "World\n"},
49
- {:text => "2", :styles => [:superscript]},
50
- ]
49
+ { :text => "Hello " },
50
+ { :text => "World\n" },
51
+ { :text => "2", :styles => [:superscript] }
52
+ ]
51
53
  text_box = Prawn::Text::Formatted::Box.new(texts, :document => @pdf, :width => @pdf.width_of("Hello World"))
52
54
  text_box.render
53
- text_box.text.should == "Hello World\n2"
55
+ expect(text_box.text).to eq("Hello World\n2")
54
56
  end
55
57
 
56
58
  it "should wrap between two fragments when the final fragment begins with white space" do
57
59
  texts = [
58
- {:text => "Hello "},
59
- {:text => "World"},
60
- {:text => " 2", :styles => [:superscript]},
61
- ]
60
+ { :text => "Hello " },
61
+ { :text => "World" },
62
+ { :text => " 2", :styles => [:superscript] }
63
+ ]
62
64
  text_box = Prawn::Text::Formatted::Box.new(texts, :document => @pdf, :width => @pdf.width_of("Hello World"))
63
65
  text_box.render
64
- text_box.text.should == "Hello World\n2"
66
+ expect(text_box.text).to eq("Hello World\n2")
65
67
 
66
68
  texts = [
67
- {:text => "Hello "},
68
- {:text => "World"},
69
- {:text => "\n2", :styles => [:superscript]},
70
- ]
69
+ { :text => "Hello " },
70
+ { :text => "World" },
71
+ { :text => "\n2", :styles => [:superscript] }
72
+ ]
71
73
  text_box = Prawn::Text::Formatted::Box.new(texts, :document => @pdf, :width => @pdf.width_of("Hello World"))
72
74
  text_box.render
73
- text_box.text.should == "Hello World\n2"
75
+ expect(text_box.text).to eq("Hello World\n2")
74
76
  end
75
77
 
76
78
  it "should properly handle empty slices using default encoding" do
77
79
  texts = [{ :text => "Noua Delineatio Geographica generalis | Apostolicarum peregrinationum | S FRANCISCI XAUERII | Indiarum & Iaponiæ Apostoli", :font => 'Courier', :size => 10 }]
78
80
  text_box = Prawn::Text::Formatted::Box.new(texts, :document => @pdf, :width => @pdf.width_of("Noua Delineatio Geographica gen"))
79
- lambda {
81
+ expect {
80
82
  text_box.render
81
- }.should_not raise_error
82
- text_box.text.should == "Noua Delineatio Geographica\ngeneralis | Apostolicarum\nperegrinationum | S FRANCISCI\nXAUERII | Indiarum & Iaponi\346\nApostoli"
83
+ }.not_to raise_error
84
+ expect(text_box.text).to eq("Noua Delineatio Geographica\ngeneralis | Apostolicarum\nperegrinationum | S FRANCISCI\nXAUERII | Indiarum & Iaponi\346\nApostoli")
83
85
  end
84
86
  end
85
87
 
86
- describe "Text::Formatted::Box with :fallback_fonts option that includes" +
88
+ describe "Text::Formatted::Box with :fallback_fonts option that includes" \
87
89
  "a Chinese font and set of Chinese glyphs not in the current font" do
88
90
  it "should change the font to the Chinese font for the Chinese glyphs" do
89
91
  create_pdf
@@ -98,20 +100,20 @@ describe "Text::Formatted::Box with :fallback_fonts option that includes" +
98
100
  text = PDF::Inspector::Text.analyze(@pdf.render)
99
101
 
100
102
  fonts_used = text.font_settings.map { |e| e[:name] }
101
- fonts_used.length.should == 4
102
- fonts_used[0].should == :"Helvetica"
103
- fonts_used[1].to_s.should =~ /GBZenKai-Medium/
104
- fonts_used[2].to_s.should =~ /GBZenKai-Medium/
105
- fonts_used[3].should == :"Helvetica"
103
+ expect(fonts_used.length).to eq(4)
104
+ expect(fonts_used[0]).to eq(:Helvetica)
105
+ expect(fonts_used[1].to_s).to match(/GBZenKai-Medium/)
106
+ expect(fonts_used[2].to_s).to match(/GBZenKai-Medium/)
107
+ expect(fonts_used[3]).to eq(:Helvetica)
106
108
 
107
- text.strings[0].should == "hello"
108
- text.strings[1].should == "你好"
109
- text.strings[2].should == "再见"
110
- text.strings[3].should == "goodbye"
109
+ expect(text.strings[0]).to eq("hello")
110
+ expect(text.strings[1]).to eq("你好")
111
+ expect(text.strings[2]).to eq("再见")
112
+ expect(text.strings[3]).to eq("goodbye")
111
113
  end
112
114
  end
113
115
 
114
- describe "Text::Formatted::Box with :fallback_fonts option that includes" +
116
+ describe "Text::Formatted::Box with :fallback_fonts option that includes" \
115
117
  "an AFM font and Win-Ansi glyph not in the current Chinese font" do
116
118
  it "should change the font to the AFM font for the Win-Ansi glyph" do
117
119
  create_pdf
@@ -127,20 +129,20 @@ describe "Text::Formatted::Box with :fallback_fonts option that includes" +
127
129
  text = PDF::Inspector::Text.analyze(@pdf.render)
128
130
 
129
131
  fonts_used = text.font_settings.map { |e| e[:name] }
130
- fonts_used.length.should == 4
131
- fonts_used[0].to_s.should =~ /GBZenKai-Medium/
132
- fonts_used[1].to_s.should =~ /GBZenKai-Medium/
133
- fonts_used[2].to_s.should =~ /GBZenKai-Medium/
134
- fonts_used[3].should == :"Helvetica"
132
+ expect(fonts_used.length).to eq(4)
133
+ expect(fonts_used[0].to_s).to match(/GBZenKai-Medium/)
134
+ expect(fonts_used[1].to_s).to match(/GBZenKai-Medium/)
135
+ expect(fonts_used[2].to_s).to match(/GBZenKai-Medium/)
136
+ expect(fonts_used[3]).to eq(:Helvetica)
135
137
 
136
- text.strings[0].should == "hello"
137
- text.strings[1].should == "你好"
138
- text.strings[2].should == "再见"
139
- text.strings[3].should == "€"
138
+ expect(text.strings[0]).to eq("hello")
139
+ expect(text.strings[1]).to eq("你好")
140
+ expect(text.strings[2]).to eq("再见")
141
+ expect(text.strings[3]).to eq("€")
140
142
  end
141
143
  end
142
144
 
143
- describe "Text::Formatted::Box with :fallback_fonts option and fragment " +
145
+ describe "Text::Formatted::Box with :fallback_fonts option and fragment " \
144
146
  "level font" do
145
147
  it "should use the fragment level font except for glyphs not in that font" do
146
148
  create_pdf
@@ -161,16 +163,16 @@ describe "Text::Formatted::Box with :fallback_fonts option and fragment " +
161
163
  text = PDF::Inspector::Text.analyze(@pdf.render)
162
164
 
163
165
  fonts_used = text.font_settings.map { |e| e[:name] }
164
- fonts_used.length.should == 4
165
- fonts_used[0].should == :"Helvetica"
166
- fonts_used[1].to_s.should =~ /GBZenKai-Medium/
167
- fonts_used[2].to_s.should =~ /GBZenKai-Medium/
168
- fonts_used[3].should == :"Times-Roman"
166
+ expect(fonts_used.length).to eq(4)
167
+ expect(fonts_used[0]).to eq(:Helvetica)
168
+ expect(fonts_used[1].to_s).to match(/GBZenKai-Medium/)
169
+ expect(fonts_used[2].to_s).to match(/GBZenKai-Medium/)
170
+ expect(fonts_used[3]).to eq(:"Times-Roman")
169
171
 
170
- text.strings[0].should == "hello"
171
- text.strings[1].should == "你好"
172
- text.strings[2].should == "再见"
173
- text.strings[3].should == "goodbye"
172
+ expect(text.strings[0]).to eq("hello")
173
+ expect(text.strings[1]).to eq("你好")
174
+ expect(text.strings[2]).to eq("再见")
175
+ expect(text.strings[3]).to eq("goodbye")
174
176
  end
175
177
  end
176
178
 
@@ -187,13 +189,12 @@ describe "Text::Formatted::Box" do
187
189
  :normal => { :file => file }
188
190
  }
189
191
 
190
-
191
192
  @formatted_text = [{ :text => "hello你好" }]
192
193
  @pdf.fallback_fonts(["Kai"])
193
194
  @pdf.fallback_fonts = ["Kai"]
194
195
  end
195
196
  it "#fallback_fonts should return the document-wide fallback fonts" do
196
- @pdf.fallback_fonts.should == ["Kai"]
197
+ expect(@pdf.fallback_fonts).to eq(["Kai"])
197
198
  end
198
199
  it "should be able to set text fallback_fonts document-wide" do
199
200
  @pdf.formatted_text_box(@formatted_text)
@@ -201,9 +202,9 @@ describe "Text::Formatted::Box" do
201
202
  text = PDF::Inspector::Text.analyze(@pdf.render)
202
203
 
203
204
  fonts_used = text.font_settings.map { |e| e[:name] }
204
- fonts_used.length.should == 2
205
- fonts_used[0].should == :"Helvetica"
206
- fonts_used[1].to_s.should =~ /GBZenKai-Medium/
205
+ expect(fonts_used.length).to eq(2)
206
+ expect(fonts_used[0]).to eq(:Helvetica)
207
+ expect(fonts_used[1].to_s).to match(/GBZenKai-Medium/)
207
208
  end
208
209
  it "should be able to override document-wide fallback_fonts" do
209
210
  @pdf.fallback_fonts = ["DejaVu Sans"]
@@ -212,11 +213,11 @@ describe "Text::Formatted::Box" do
212
213
  text = PDF::Inspector::Text.analyze(@pdf.render)
213
214
 
214
215
  fonts_used = text.font_settings.map { |e| e[:name] }
215
- fonts_used.length.should == 2
216
- fonts_used[0].should == :"Helvetica"
217
- fonts_used[1].should =~ /Kai/
216
+ expect(fonts_used.length).to eq(2)
217
+ expect(fonts_used[0]).to eq(:Helvetica)
218
+ expect(fonts_used[1]).to match(/Kai/)
218
219
  end
219
- it "should omit the fallback fonts overhead when passing an empty array " +
220
+ it "should omit the fallback fonts overhead when passing an empty array " \
220
221
  "as the :fallback_fonts" do
221
222
  @pdf.font("Kai")
222
223
 
@@ -240,17 +241,16 @@ describe "Text::Formatted::Box" do
240
241
  end
241
242
  end
242
243
 
243
- describe "Text::Formatted::Box with :fallback_fonts option " +
244
+ describe "Text::Formatted::Box with :fallback_fonts option " \
244
245
  "with glyphs not in the primary or the fallback fonts" do
245
-
246
246
  it "should raise an exception" do
247
- file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
247
+ file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
248
248
  create_pdf
249
249
  formatted_text = [{ :text => "hello world. 世界你好。" }]
250
250
 
251
- lambda {
251
+ expect {
252
252
  @pdf.formatted_text_box(formatted_text, :fallback_fonts => ["Courier"])
253
- }.should raise_error(Prawn::Errors::IncompatibleStringEncoding)
253
+ }.to raise_error(Prawn::Errors::IncompatibleStringEncoding)
254
254
  end
255
255
  end
256
256
 
@@ -261,16 +261,16 @@ describe "Text::Formatted::Box#extensions" do
261
261
  @pdf.formatted_text_box([{ :text => "hello world" }], {})
262
262
  Prawn::Text::Formatted::Box.extensions.delete(TestFormattedWrapOverride)
263
263
  text = PDF::Inspector::Text.analyze(@pdf.render)
264
- text.strings[0].should == "all your base are belong to us"
264
+ expect(text.strings[0]).to eq("all your base are belong to us")
265
265
  end
266
- it "overriding Text::Formatted::Box line wrapping should not affect " +
266
+ it "overriding Text::Formatted::Box line wrapping should not affect " \
267
267
  "Text::Box wrapping" do
268
268
  create_pdf
269
269
  Prawn::Text::Formatted::Box.extensions << TestFormattedWrapOverride
270
270
  @pdf.text_box("hello world", {})
271
271
  Prawn::Text::Formatted::Box.extensions.delete(TestFormattedWrapOverride)
272
272
  text = PDF::Inspector::Text.analyze(@pdf.render)
273
- text.strings[0].should == "hello world"
273
+ expect(text.strings[0]).to eq("hello world")
274
274
  end
275
275
  it "overriding Text::Box line wrapping should override Text::Box wrapping" do
276
276
  create_pdf
@@ -278,73 +278,73 @@ describe "Text::Formatted::Box#extensions" do
278
278
  @pdf.text_box("hello world", {})
279
279
  Prawn::Text::Box.extensions.delete(TestFormattedWrapOverride)
280
280
  text = PDF::Inspector::Text.analyze(@pdf.render)
281
- text.strings[0].should == "all your base are belong to us"
281
+ expect(text.strings[0]).to eq("all your base are belong to us")
282
282
  end
283
283
  end
284
284
 
285
285
  describe "Text::Formatted::Box#render" do
286
286
  it "should handle newlines" do
287
287
  create_pdf
288
- array = [{ :text => "hello\nworld"}]
288
+ array = [{ :text => "hello\nworld" }]
289
289
  options = { :document => @pdf }
290
290
  text_box = Prawn::Text::Formatted::Box.new(array, options)
291
291
  text_box.render
292
- text_box.text.should == "hello\nworld"
292
+ expect(text_box.text).to eq("hello\nworld")
293
293
  end
294
294
  it "should omit spaces from the beginning of the line" do
295
295
  create_pdf
296
- array = [{ :text => " hello\n world"}]
296
+ array = [{ :text => " hello\n world" }]
297
297
  options = { :document => @pdf }
298
298
  text_box = Prawn::Text::Formatted::Box.new(array, options)
299
299
  text_box.render
300
- text_box.text.should == "hello\nworld"
300
+ expect(text_box.text).to eq("hello\nworld")
301
301
  end
302
302
  it "should be okay printing a line of whitespace" do
303
303
  create_pdf
304
- array = [{ :text => "hello\n \nworld"}]
304
+ array = [{ :text => "hello\n \nworld" }]
305
305
  options = { :document => @pdf }
306
306
  text_box = Prawn::Text::Formatted::Box.new(array, options)
307
307
  text_box.render
308
- text_box.text.should == "hello\n\nworld"
308
+ expect(text_box.text).to eq("hello\n\nworld")
309
309
 
310
-
311
- array = [{ :text => "hello" + " " * 500},
310
+ array = [{ :text => "hello" + " " * 500 },
312
311
  { :text => " " * 500 },
313
- { :text => " " * 500 + "\n"},
314
- { :text => "world"}]
312
+ { :text => " " * 500 + "\n" },
313
+ { :text => "world" }]
315
314
  options = { :document => @pdf }
316
315
  text_box = Prawn::Text::Formatted::Box.new(array, options)
317
316
  text_box.render
318
- text_box.text.should == "hello\n\nworld"
317
+ expect(text_box.text).to eq("hello\n\nworld")
319
318
  end
320
319
  it "should enable fragment level direction setting" do
321
320
  create_pdf
322
321
  number_of_hellos = 18
323
322
  array = [
324
- { :text => "hello " * number_of_hellos },
325
- { :text => "world", :direction => :ltr },
326
- { :text => ", how are you?" }
327
- ]
323
+ { :text => "hello " * number_of_hellos },
324
+ { :text => "world", :direction => :ltr },
325
+ { :text => ", how are you?" }
326
+ ]
328
327
  options = { :document => @pdf, :direction => :rtl }
329
328
  text_box = Prawn::Text::Formatted::Box.new(array, options)
330
329
  text_box.render
331
330
  text = PDF::Inspector::Text.analyze(@pdf.render)
332
- text.strings[0].should == "era woh ,"
333
- text.strings[1].should == "world"
334
- text.strings[2].should == " olleh" * number_of_hellos
335
- text.strings[3].should == "?uoy"
331
+ expect(text.strings[0]).to eq("era woh ,")
332
+ expect(text.strings[1]).to eq("world")
333
+ expect(text.strings[2]).to eq(" olleh" * number_of_hellos)
334
+ expect(text.strings[3]).to eq("?uoy")
336
335
  end
337
336
  end
338
337
 
339
338
  describe "Text::Formatted::Box#render" do
340
339
  it "should be able to perform fragment callbacks" do
341
340
  create_pdf
342
- callback_object = TestFragmentCallback.new("something", 7,
343
- :document => @pdf)
341
+ callback_object = TestFragmentCallback.new("something", 7, :document => @pdf)
344
342
  callback_object.expects(:render_behind).with(
345
- kind_of(Prawn::Text::Formatted::Fragment))
343
+ kind_of(Prawn::Text::Formatted::Fragment)
344
+ )
346
345
  callback_object.expects(:render_in_front).with(
347
- kind_of(Prawn::Text::Formatted::Fragment))
346
+ kind_of(Prawn::Text::Formatted::Fragment)
347
+ )
348
348
  array = [{ :text => "hello world " },
349
349
  { :text => "callback now",
350
350
  :callback => callback_object }]
@@ -354,19 +354,21 @@ describe "Text::Formatted::Box#render" do
354
354
  it "should be able to perform fragment callbacks on multiple objects" do
355
355
  create_pdf
356
356
 
357
- callback_object = TestFragmentCallback.new("something", 7,
358
- :document => @pdf)
357
+ callback_object = TestFragmentCallback.new("something", 7, :document => @pdf)
359
358
  callback_object.expects(:render_behind).with(
360
- kind_of(Prawn::Text::Formatted::Fragment))
359
+ kind_of(Prawn::Text::Formatted::Fragment)
360
+ )
361
361
  callback_object.expects(:render_in_front).with(
362
- kind_of(Prawn::Text::Formatted::Fragment))
362
+ kind_of(Prawn::Text::Formatted::Fragment)
363
+ )
363
364
 
364
- callback_object2 = TestFragmentCallback.new("something else", 14,
365
- :document => @pdf)
365
+ callback_object2 = TestFragmentCallback.new("something else", 14, :document => @pdf)
366
366
  callback_object2.expects(:render_behind).with(
367
- kind_of(Prawn::Text::Formatted::Fragment))
367
+ kind_of(Prawn::Text::Formatted::Fragment)
368
+ )
368
369
  callback_object2.expects(:render_in_front).with(
369
- kind_of(Prawn::Text::Formatted::Fragment))
370
+ kind_of(Prawn::Text::Formatted::Fragment)
371
+ )
370
372
 
371
373
  array = [{ :text => "hello world " },
372
374
  { :text => "callback now",
@@ -398,10 +400,10 @@ describe "Text::Formatted::Box#render" do
398
400
  text_box.render
399
401
  contents = PDF::Inspector::Text.analyze(@pdf.render)
400
402
  fonts = contents.font_settings.map { |e| e[:name] }
401
- fonts.should == [:Helvetica, :"Times-Bold", :Helvetica]
402
- contents.strings[0].should == "this contains "
403
- contents.strings[1].should == "Times-Bold"
404
- contents.strings[2].should == " text"
403
+ expect(fonts).to eq([:Helvetica, :"Times-Bold", :Helvetica])
404
+ expect(contents.strings[0]).to eq("this contains ")
405
+ expect(contents.strings[1]).to eq("Times-Bold")
406
+ expect(contents.strings[2]).to eq(" text")
405
407
  end
406
408
  it "should be able to set bold" do
407
409
  create_pdf
@@ -412,10 +414,10 @@ describe "Text::Formatted::Box#render" do
412
414
  text_box.render
413
415
  contents = PDF::Inspector::Text.analyze(@pdf.render)
414
416
  fonts = contents.font_settings.map { |e| e[:name] }
415
- fonts.should == [:Helvetica, :"Helvetica-Bold", :Helvetica]
416
- contents.strings[0].should == "this contains "
417
- contents.strings[1].should == "bold"
418
- contents.strings[2].should == " text"
417
+ expect(fonts).to eq([:Helvetica, :"Helvetica-Bold", :Helvetica])
418
+ expect(contents.strings[0]).to eq("this contains ")
419
+ expect(contents.strings[1]).to eq("bold")
420
+ expect(contents.strings[2]).to eq(" text")
419
421
  end
420
422
  it "should be able to set italics" do
421
423
  create_pdf
@@ -426,7 +428,7 @@ describe "Text::Formatted::Box#render" do
426
428
  text_box.render
427
429
  contents = PDF::Inspector::Text.analyze(@pdf.render)
428
430
  fonts = contents.font_settings.map { |e| e[:name] }
429
- fonts.should == [:Helvetica, :"Helvetica-Oblique", :Helvetica]
431
+ expect(fonts).to eq([:Helvetica, :"Helvetica-Oblique", :Helvetica])
430
432
  end
431
433
  it "should be able to set subscript" do
432
434
  create_pdf
@@ -436,8 +438,8 @@ describe "Text::Formatted::Box#render" do
436
438
  text_box = Prawn::Text::Formatted::Box.new(array, :document => @pdf)
437
439
  text_box.render
438
440
  contents = PDF::Inspector::Text.analyze(@pdf.render)
439
- contents.font_settings[0][:size].should == 12
440
- contents.font_settings[1][:size].should be_within(0.0001).of(18 * 0.583)
441
+ expect(contents.font_settings[0][:size]).to eq(12)
442
+ expect(contents.font_settings[1][:size]).to be_within(0.0001).of(18 * 0.583)
441
443
  end
442
444
  it "should be able to set superscript" do
443
445
  create_pdf
@@ -447,8 +449,8 @@ describe "Text::Formatted::Box#render" do
447
449
  text_box = Prawn::Text::Formatted::Box.new(array, :document => @pdf)
448
450
  text_box.render
449
451
  contents = PDF::Inspector::Text.analyze(@pdf.render)
450
- contents.font_settings[0][:size].should == 12
451
- contents.font_settings[1][:size].should be_within(0.0001).of(18 * 0.583)
452
+ expect(contents.font_settings[0][:size]).to eq(12)
453
+ expect(contents.font_settings[1][:size]).to be_within(0.0001).of(18 * 0.583)
452
454
  end
453
455
  it "should be able to set compound bold and italic text" do
454
456
  create_pdf
@@ -459,7 +461,7 @@ describe "Text::Formatted::Box#render" do
459
461
  text_box.render
460
462
  contents = PDF::Inspector::Text.analyze(@pdf.render)
461
463
  fonts = contents.font_settings.map { |e| e[:name] }
462
- fonts.should == [:Helvetica, :"Helvetica-BoldOblique", :Helvetica]
464
+ expect(fonts).to eq([:Helvetica, :"Helvetica-BoldOblique", :Helvetica])
463
465
  end
464
466
  it "should be able to underline" do
465
467
  create_pdf
@@ -469,7 +471,7 @@ describe "Text::Formatted::Box#render" do
469
471
  text_box = Prawn::Text::Formatted::Box.new(array, :document => @pdf)
470
472
  text_box.render
471
473
  line_drawing = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
472
- line_drawing.points.length.should == 2
474
+ expect(line_drawing.points.length).to eq(2)
473
475
  end
474
476
  it "should be able to strikethrough" do
475
477
  create_pdf
@@ -479,12 +481,16 @@ describe "Text::Formatted::Box#render" do
479
481
  text_box = Prawn::Text::Formatted::Box.new(array, :document => @pdf)
480
482
  text_box.render
481
483
  line_drawing = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
482
- line_drawing.points.length.should == 2
484
+ expect(line_drawing.points.length).to eq(2)
483
485
  end
484
486
  it "should be able to add URL links" do
485
487
  create_pdf
486
- @pdf.expects(:link_annotation).with(kind_of(Array), :Border => [0,0,0],
487
- :A => { :Type => :Action, :S => :URI, :URI => "http://example.com" })
488
+ @pdf.expects(:link_annotation).with(kind_of(Array), :Border => [0, 0, 0],
489
+ :A => {
490
+ :Type => :Action,
491
+ :S => :URI,
492
+ :URI => "http://example.com"
493
+ })
488
494
  array = [{ :text => "click " },
489
495
  { :text => "here", :link => "http://example.com" },
490
496
  { :text => " to visit" }]
@@ -493,8 +499,8 @@ describe "Text::Formatted::Box#render" do
493
499
  end
494
500
  it "should be able to add destination links" do
495
501
  create_pdf
496
- @pdf.expects(:link_annotation).with(kind_of(Array), :Border => [0,0,0],
497
- :Dest => "ToC")
502
+ @pdf.expects(:link_annotation).with(kind_of(Array), :Border => [0, 0, 0],
503
+ :Dest => "ToC")
498
504
  array = [{ :text => "Go to the " },
499
505
  { :text => "Table of Contents", :anchor => "ToC" }]
500
506
  text_box = Prawn::Text::Formatted::Box.new(array, :document => @pdf)
@@ -502,8 +508,13 @@ describe "Text::Formatted::Box#render" do
502
508
  end
503
509
  it "should be able to add local actions" do
504
510
  create_pdf
505
- @pdf.expects(:link_annotation).with(kind_of(Array), :Border => [0,0,0],
506
- :A => { :Type => :Action, :S => :Launch, :F => "../example.pdf", :NewWindow => true })
511
+ @pdf.expects(:link_annotation).with(kind_of(Array), :Border => [0, 0, 0],
512
+ :A => {
513
+ :Type => :Action,
514
+ :S => :Launch,
515
+ :F => "../example.pdf",
516
+ :NewWindow => true
517
+ })
507
518
  array = [{ :text => "click " },
508
519
  { :text => "here", :local => "../example.pdf" },
509
520
  { :text => " to open a local file" }]
@@ -518,8 +529,8 @@ describe "Text::Formatted::Box#render" do
518
529
  text_box = Prawn::Text::Formatted::Box.new(array, :document => @pdf)
519
530
  text_box.render
520
531
  contents = PDF::Inspector::Text.analyze(@pdf.render)
521
- contents.font_settings[0][:size].should == 12
522
- contents.font_settings[1][:size].should == 24
532
+ expect(contents.font_settings[0][:size]).to eq(12)
533
+ expect(contents.font_settings[1][:size]).to eq(24)
523
534
  end
524
535
  it "should set the baseline based on the tallest fragment on a given line" do
525
536
  create_pdf
@@ -529,7 +540,7 @@ describe "Text::Formatted::Box#render" do
529
540
  text_box = Prawn::Text::Formatted::Box.new(array, :document => @pdf)
530
541
  text_box.render
531
542
  @pdf.font_size(24) do
532
- text_box.height.should be_within(0.001).of(@pdf.font.ascender + @pdf.font.descender)
543
+ expect(text_box.height).to be_within(0.001).of(@pdf.font.ascender + @pdf.font.descender)
533
544
  end
534
545
  end
535
546
  it "should be able to set color via an rgb hex string" do
@@ -539,8 +550,8 @@ describe "Text::Formatted::Box#render" do
539
550
  text_box = Prawn::Text::Formatted::Box.new(array, :document => @pdf)
540
551
  text_box.render
541
552
  colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render)
542
- colors.fill_color_count.should == 2
543
- colors.stroke_color_count.should == 2
553
+ expect(colors.fill_color_count).to eq(2)
554
+ expect(colors.stroke_color_count).to eq(2)
544
555
  end
545
556
  it "should be able to set color using a cmyk array" do
546
557
  create_pdf
@@ -549,8 +560,8 @@ describe "Text::Formatted::Box#render" do
549
560
  text_box = Prawn::Text::Formatted::Box.new(array, :document => @pdf)
550
561
  text_box.render
551
562
  colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render)
552
- colors.fill_color_count.should == 2
553
- colors.stroke_color_count.should == 2
563
+ expect(colors.fill_color_count).to eq(2)
564
+ expect(colors.stroke_color_count).to eq(2)
554
565
  end
555
566
  end
556
567
 
@@ -570,9 +581,9 @@ describe "Text::Formatted::Box#render(:dry_run => true)" do
570
581
  text_box.render(:dry_run => true)
571
582
 
572
583
  state_after = PDF::Inspector::Graphics::Color.analyze(@pdf.render)
573
- state_after.fill_color_count.should == fill_color_count
574
- state_after.stroke_color_count.should == stroke_color_count
575
- state_after.stroke_color_space_count.should == stroke_color_space_count
584
+ expect(state_after.fill_color_count).to eq(fill_color_count)
585
+ expect(state_after.stroke_color_count).to eq(stroke_color_count)
586
+ expect(state_after.stroke_color_space_count).to eq(stroke_color_space_count)
576
587
  end
577
588
  end
578
589
 
@@ -585,7 +596,7 @@ describe "Text::Formatted::Box#render with fragment level :character_spacing opt
585
596
  text_box = Prawn::Text::Formatted::Box.new(array, options)
586
597
  text_box.render
587
598
  contents = PDF::Inspector::Text.analyze(@pdf.render)
588
- contents.character_spacing[0].should == 7
599
+ expect(contents.character_spacing[0]).to eq(7)
589
600
  end
590
601
  it "should draw the character spacing to the document" do
591
602
  create_pdf
@@ -597,7 +608,7 @@ describe "Text::Formatted::Box#render with fragment level :character_spacing opt
597
608
  :overflow => :expand }
598
609
  text_box = Prawn::Text::Formatted::Box.new(array, options)
599
610
  text_box.render
600
- text_box.text.should == "hello\nworld"
611
+ expect(text_box.text).to eq("hello\nworld")
601
612
  end
602
613
  end
603
614
 
@@ -611,7 +622,7 @@ describe "Text::Formatted::Box#render with :align => :justify" do
611
622
  text_box = Prawn::Text::Formatted::Box.new(array, options)
612
623
  text_box.render
613
624
  contents = PDF::Inspector::Text.analyze(@pdf.render)
614
- contents.word_spacing.should be_empty
625
+ expect(contents.word_spacing).to be_empty
615
626
  end
616
627
  end
617
628
 
@@ -622,19 +633,19 @@ describe "Text::Formatted::Box#render with :valign => :center" do
622
633
  y = 450
623
634
  array = [{ :text => 'Vertical Align' }]
624
635
  options = {
625
- :document => @pdf,
626
- :valign => :center,
627
- :at => [0,y],
628
- :width => 100,
629
- :height => box_height,
630
- :size => 16
636
+ :document => @pdf,
637
+ :valign => :center,
638
+ :at => [0, y],
639
+ :width => 100,
640
+ :height => box_height,
641
+ :size => 16
631
642
  }
632
643
  text_box = Prawn::Text::Formatted::Box.new(array, options)
633
644
  text_box.render
634
645
  line_padding = (box_height - text_box.height + text_box.descender) * 0.5
635
646
  baseline = y - line_padding
636
647
 
637
- text_box.at[1].should be_within(0.01).of(baseline)
648
+ expect(text_box.at[1]).to be_within(0.01).of(baseline)
638
649
  end
639
650
  end
640
651
 
@@ -645,18 +656,18 @@ describe "Text::Formatted::Box#render with :valign => :bottom" do
645
656
  y = 450
646
657
  array = [{ :text => 'Vertical Align' }]
647
658
  options = {
648
- :document => @pdf,
649
- :valign => :bottom,
650
- :at => [0,y],
651
- :width => 100,
652
- :height => box_height,
653
- :size => 16
659
+ :document => @pdf,
660
+ :valign => :bottom,
661
+ :at => [0, y],
662
+ :width => 100,
663
+ :height => box_height,
664
+ :size => 16
654
665
  }
655
666
  text_box = Prawn::Text::Formatted::Box.new(array, options)
656
667
  text_box.render
657
668
  top_padding = y - (box_height - text_box.height)
658
669
 
659
- text_box.at[1].should be_within(0.01).of(top_padding)
670
+ expect(text_box.at[1]).to be_within(0.01).of(top_padding)
660
671
  end
661
672
  end
662
673