prawn 2.3.0 → 2.4.0

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 (91) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Rakefile +2 -31
  5. data/lib/prawn.rb +1 -0
  6. data/lib/prawn/document.rb +20 -15
  7. data/lib/prawn/document/bounding_box.rb +10 -2
  8. data/lib/prawn/document/span.rb +2 -1
  9. data/lib/prawn/font.rb +6 -4
  10. data/lib/prawn/font_metric_cache.rb +7 -6
  11. data/lib/prawn/fonts/afm.rb +18 -16
  12. data/lib/prawn/fonts/ttf.rb +55 -29
  13. data/lib/prawn/graphics.rb +11 -11
  14. data/lib/prawn/graphics/color.rb +18 -16
  15. data/lib/prawn/graphics/join_style.rb +1 -1
  16. data/lib/prawn/graphics/patterns.rb +57 -49
  17. data/lib/prawn/graphics/transformation.rb +3 -3
  18. data/lib/prawn/grid.rb +36 -1
  19. data/lib/prawn/images.rb +29 -27
  20. data/lib/prawn/images/jpg.rb +4 -1
  21. data/lib/prawn/images/png.rb +2 -1
  22. data/lib/prawn/outline.rb +6 -5
  23. data/lib/prawn/repeater.rb +1 -1
  24. data/lib/prawn/security.rb +39 -36
  25. data/lib/prawn/text.rb +18 -18
  26. data/lib/prawn/text/box.rb +10 -9
  27. data/lib/prawn/text/formatted/arranger.rb +38 -19
  28. data/lib/prawn/text/formatted/box.rb +20 -15
  29. data/lib/prawn/text/formatted/line_wrap.rb +18 -16
  30. data/lib/prawn/text/formatted/parser.rb +28 -26
  31. data/lib/prawn/text/formatted/wrap.rb +15 -11
  32. data/lib/prawn/version.rb +1 -1
  33. data/lib/prawn/view.rb +2 -2
  34. data/manual/basic_concepts/measurement.rb +1 -1
  35. data/manual/bounding_box/canvas.rb +3 -3
  36. data/manual/bounding_box/nesting.rb +1 -1
  37. data/manual/document_and_page_options/background.rb +6 -2
  38. data/manual/document_and_page_options/document_and_page_options.rb +3 -3
  39. data/manual/document_and_page_options/print_scaling.rb +2 -1
  40. data/manual/graphics/common_lines.rb +1 -1
  41. data/manual/graphics/fill_and_stroke.rb +1 -1
  42. data/manual/graphics/fill_rules.rb +4 -3
  43. data/manual/graphics/helper.rb +11 -4
  44. data/manual/graphics/lines_and_curves.rb +1 -1
  45. data/manual/graphics/stroke_dash.rb +5 -5
  46. data/manual/graphics/translate.rb +2 -1
  47. data/manual/images/horizontal.rb +2 -2
  48. data/manual/images/scale.rb +3 -3
  49. data/manual/images/vertical.rb +6 -3
  50. data/manual/images/width_and_height.rb +3 -3
  51. data/manual/layout/content.rb +2 -2
  52. data/manual/outline/outline.rb +1 -1
  53. data/manual/security/permissions.rb +4 -2
  54. data/manual/security/security.rb +1 -1
  55. data/manual/text/alignment.rb +2 -2
  56. data/manual/text/column_box.rb +2 -2
  57. data/manual/text/font_style.rb +5 -2
  58. data/manual/text/formatted_callbacks.rb +17 -12
  59. data/manual/text/formatted_text.rb +7 -4
  60. data/manual/text/free_flowing_text.rb +3 -3
  61. data/manual/text/kerning_and_character_spacing.rb +4 -4
  62. data/manual/text/paragraph_indentation.rb +4 -5
  63. data/manual/text/rendering_and_color.rb +1 -1
  64. data/manual/text/right_to_left_text.rb +6 -6
  65. data/manual/text/rotation.rb +8 -3
  66. data/manual/text/text_box_extensions.rb +1 -1
  67. data/manual/text/text_box_overflow.rb +11 -9
  68. data/manual/text/win_ansi_charset.rb +9 -9
  69. data/prawn.gemspec +4 -10
  70. data/spec/prawn/document/bounding_box_spec.rb +82 -78
  71. data/spec/prawn/document/security_spec.rb +1 -1
  72. data/spec/prawn/document_span_spec.rb +14 -6
  73. data/spec/prawn/document_spec.rb +29 -26
  74. data/spec/prawn/font_spec.rb +16 -14
  75. data/spec/prawn/graphics_spec.rb +79 -44
  76. data/spec/prawn/images_spec.rb +13 -8
  77. data/spec/prawn/outline_spec.rb +127 -27
  78. data/spec/prawn/repeater_spec.rb +9 -8
  79. data/spec/prawn/soft_mask_spec.rb +1 -1
  80. data/spec/prawn/stamp_spec.rb +3 -2
  81. data/spec/prawn/text/box_spec.rb +57 -59
  82. data/spec/prawn/text/formatted/arranger_spec.rb +10 -10
  83. data/spec/prawn/text/formatted/box_spec.rb +8 -5
  84. data/spec/prawn/text/formatted/line_wrap_spec.rb +2 -1
  85. data/spec/prawn/text_draw_text_spec.rb +9 -8
  86. data/spec/prawn/text_spacing_spec.rb +2 -2
  87. data/spec/prawn/text_spec.rb +9 -9
  88. data/spec/prawn/text_with_inline_formatting_spec.rb +1 -1
  89. data/spec/prawn_manual_spec.rb +4 -4
  90. metadata +14 -98
  91. metadata.gz.sig +0 -0
@@ -36,7 +36,7 @@ describe Prawn::Document::Security do
36
36
  pdf = Prawn::Document.new
37
37
 
38
38
  # Make things easier to test
39
- pdf.singleton_class.send :public, :permissions_value
39
+ pdf.singleton_class.__send__ :public, :permissions_value
40
40
  # class << pdf
41
41
  # public :permissions_value
42
42
  # end
@@ -7,12 +7,19 @@ describe Prawn::Document do
7
7
 
8
8
  it 'onlies accept :position as option in debug mode' do
9
9
  Prawn.debug = true
10
- expect { pdf.span(350, x: 3) {} }
11
- .to raise_error(Prawn::Errors::UnknownOption)
10
+ expect do
11
+ pdf.span(350, x: 3) do
12
+ # draw
13
+ end
14
+ end.to raise_error(Prawn::Errors::UnknownOption)
12
15
  end
13
16
 
14
17
  it 'has raise an error if :position is invalid' do
15
- expect { pdf.span(350, position: :x) {} }.to raise_error(ArgumentError)
18
+ expect do
19
+ pdf.span(350, position: :x) do
20
+ # draw
21
+ end
22
+ end.to raise_error(ArgumentError)
16
23
  end
17
24
 
18
25
  it 'restores the margin box when bounding box exits' do
@@ -26,9 +33,10 @@ describe Prawn::Document do
26
33
  end
27
34
 
28
35
  it 'does create a margin box' do
29
- margin_box = pdf.span(350, position: :center) do
30
- pdf.text "Here's some centered text in a 350 point column. " * 100
31
- end
36
+ margin_box =
37
+ pdf.span(350, position: :center) do
38
+ pdf.text "Here's some centered text in a 350 point column. " * 100
39
+ end
32
40
 
33
41
  expect(margin_box.top).to eq(792.0)
34
42
  expect(margin_box.bottom).to eq(0)
@@ -34,23 +34,24 @@ describe Prawn::Document do
34
34
 
35
35
  describe 'when generating a document with a custom text formatter' do
36
36
  it 'uses the provided text formatter' do
37
- text_formatter = Class.new do
38
- def self.format(string)
39
- [
40
- {
41
- text: string.gsub('Dr. Who?', "Just 'The Doctor'."),
42
- styles: [],
43
- color: nil,
44
- link: nil,
45
- anchor: nil,
46
- local: nil,
47
- font: nil,
48
- size: nil,
49
- character_spacing: nil
50
- }
51
- ]
37
+ text_formatter =
38
+ Class.new do
39
+ def self.format(string)
40
+ [
41
+ {
42
+ text: string.gsub('Dr. Who?', "Just 'The Doctor'."),
43
+ styles: [],
44
+ color: nil,
45
+ link: nil,
46
+ anchor: nil,
47
+ local: nil,
48
+ font: nil,
49
+ size: nil,
50
+ character_spacing: nil
51
+ }
52
+ ]
53
+ end
52
54
  end
53
- end
54
55
  pdf = described_class.new text_formatter: text_formatter
55
56
  pdf.text 'Dr. Who?', inline_format: true
56
57
  text = PDF::Inspector::Text.analyze(pdf.render)
@@ -331,13 +332,14 @@ describe Prawn::Document do
331
332
 
332
333
  describe 'When reopening pages' do
333
334
  it 'modifies the content stream size' do
334
- pdf = described_class.new do
335
- text 'Page 1'
336
- start_new_page
337
- text 'Page 2'
338
- go_to_page 1
339
- text 'More for page 1'
340
- end
335
+ pdf =
336
+ described_class.new do
337
+ text 'Page 1'
338
+ start_new_page
339
+ text 'Page 2'
340
+ go_to_page 1
341
+ text 'More for page 1'
342
+ end
341
343
 
342
344
  # Indirectly verify that the actual length does not match dictionary
343
345
  # length. If it isn't, a MalformedPDFError will be raised
@@ -364,9 +366,10 @@ describe Prawn::Document do
364
366
  end
365
367
 
366
368
  it 'restores the layout of the page' do
367
- doc = described_class.new do
368
- start_new_page layout: :landscape
369
- end
369
+ doc =
370
+ described_class.new do
371
+ start_new_page layout: :landscape
372
+ end
370
373
 
371
374
  lsize = [doc.bounds.width, doc.bounds.height]
372
375
 
@@ -217,18 +217,19 @@ describe Prawn::Font do
217
217
  end
218
218
 
219
219
  it 'accepts IO objects for font files' do
220
- io = File.open "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
221
- pdf.font_families['DejaVu Sans'] = {
222
- normal: described_class.load(pdf, io)
223
- }
220
+ File.open "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf" do |io|
221
+ pdf.font_families['DejaVu Sans'] = {
222
+ normal: described_class.load(pdf, io)
223
+ }
224
224
 
225
- pdf.font 'DejaVu Sans'
226
- pdf.text 'In DejaVu Sans'
225
+ pdf.font 'DejaVu Sans'
226
+ pdf.text 'In DejaVu Sans'
227
227
 
228
- text = PDF::Inspector::Text.analyze(pdf.render)
229
- name = text.font_settings.map { |e| e[:name] }.first.to_s
230
- name = name.sub(/\w+\+/, 'subset+')
231
- expect(name).to eq('subset+DejaVuSans')
228
+ text = PDF::Inspector::Text.analyze(pdf.render)
229
+ name = text.font_settings.map { |e| e[:name] }.first.to_s
230
+ name = name.sub(/\w+\+/, 'subset+')
231
+ expect(name).to eq('subset+DejaVuSans')
232
+ end
232
233
  end
233
234
  end
234
235
 
@@ -314,7 +315,8 @@ describe Prawn::Font do
314
315
  .to eq(13.332)
315
316
  expect(times.compute_width_of(
316
317
  win1252_string('To'),
317
- size: 12, kerning: true
318
+ size: 12,
319
+ kerning: true
318
320
  )).to eq(12.372)
319
321
 
320
322
  input = win1252_string("T\xF6") # Tö in win-1252
@@ -356,7 +358,7 @@ describe Prawn::Font do
356
358
 
357
359
  it 'omits /Encoding for symbolic fonts' do
358
360
  zapf = pdf.find_font 'ZapfDingbats'
359
- font_dict = zapf.send(:register, nil)
361
+ font_dict = zapf.__send__(:register, nil)
360
362
  expect(font_dict.data[:Encoding]).to be_nil
361
363
  end
362
364
  end
@@ -439,7 +441,7 @@ describe Prawn::Font do
439
441
  # These metrics are relative to the font's own bbox. They should not be
440
442
  # scaled with font size.
441
443
  ref = pdf.ref!({})
442
- font.send :embed, ref, 0
444
+ font.__send__(:embed, ref, 0)
443
445
 
444
446
  # Pull out the embedded font descriptor
445
447
  descriptor = ref.data[:FontDescriptor].data
@@ -470,7 +472,7 @@ describe Prawn::Font do
470
472
  # These metrics are relative to the font's own bbox. They should not be
471
473
  # scaled with font size.
472
474
  ref = pdf.ref!({})
473
- font.send :embed, ref, 0
475
+ font.__send__(:embed, ref, 0)
474
476
 
475
477
  # Pull out the embedded font descriptor
476
478
  descriptor = ref.data[:FontDescriptor].data
@@ -137,10 +137,10 @@ describe Prawn::Graphics do
137
137
  it 'draws a rectangle by connecting lines with rounded bezier curves' do
138
138
  expect(all_coords).to eq(
139
139
  [
140
- [60.0, 550.0], [90.0, 550.0], [95.5228, 550.0], [100.0, 545.5228],
141
- [100.0, 540.0], [100.0, 460.0], [100.0, 454.4772], [95.5228, 450.0],
142
- [90.0, 450.0], [60.0, 450.0], [54.4772, 450.0], [50.0, 454.4772],
143
- [50.0, 460.0], [50.0, 540.0], [50.0, 545.5228], [54.4772, 550.0],
140
+ [60.0, 550.0], [90.0, 550.0], [95.52285, 550.0], [100.0, 545.52285],
141
+ [100.0, 540.0], [100.0, 460.0], [100.0, 454.47715], [95.52285, 450.0],
142
+ [90.0, 450.0], [60.0, 450.0], [54.47715, 450.0], [50.0, 454.47715],
143
+ [50.0, 460.0], [50.0, 540.0], [50.0, 545.52285], [54.47715, 550.0],
144
144
  [60.0, 550.0]
145
145
  ]
146
146
  )
@@ -161,20 +161,20 @@ describe Prawn::Graphics do
161
161
  expect(curve.coords).to eq([
162
162
  125.0, 100.0,
163
163
 
164
- 125.0, 127.6142,
165
- 113.8071, 150,
164
+ 125.0, 127.61424,
165
+ 113.80712, 150,
166
166
  100.0, 150.0,
167
167
 
168
- 86.1929, 150.0,
169
- 75.0, 127.6142,
168
+ 86.19288, 150.0,
169
+ 75.0, 127.61424,
170
170
  75.0, 100.0,
171
171
 
172
- 75.0, 72.3858,
173
- 86.1929, 50.0,
172
+ 75.0, 72.38576,
173
+ 86.19288, 50.0,
174
174
  100.0, 50.0,
175
175
 
176
- 113.8071, 50.0,
177
- 125.0, 72.3858,
176
+ 113.80712, 50.0,
177
+ 125.0, 72.38576,
178
178
  125.0, 100.0,
179
179
 
180
180
  100.0, 100.0
@@ -285,7 +285,8 @@ describe Prawn::Graphics do
285
285
  pdf.fill_gradient(
286
286
  [0, pdf.bounds.height],
287
287
  [pdf.bounds.width, pdf.bounds.height],
288
- 'FF0000', '0000FF'
288
+ 'FF0000',
289
+ '0000FF'
289
290
  )
290
291
 
291
292
  grad = PDF::Inspector::Graphics::Pattern.analyze(pdf.render)
@@ -306,12 +307,14 @@ describe Prawn::Graphics do
306
307
  pdf.fill_gradient(
307
308
  [256, 512],
308
309
  [356, 512],
309
- 'ffffff', 'fe00ff'
310
+ 'ffffff',
311
+ 'fe00ff'
310
312
  )
311
313
  pdf.fill_gradient(
312
314
  [256, 256],
313
315
  [356, 256],
314
- 'ffffff', '0000ff'
316
+ 'ffffff',
317
+ '0000ff'
315
318
  )
316
319
 
317
320
  str = pdf.render
@@ -323,7 +326,8 @@ describe Prawn::Graphics do
323
326
  pdf.fill_gradient(
324
327
  [0, pdf.bounds.height],
325
328
  [pdf.bounds.width, pdf.bounds.height],
326
- 'FF0000', '0000FF'
329
+ 'FF0000',
330
+ '0000FF'
327
331
  )
328
332
 
329
333
  str = pdf.render
@@ -334,7 +338,8 @@ describe Prawn::Graphics do
334
338
  pdf.stroke_gradient(
335
339
  [0, pdf.bounds.height],
336
340
  [pdf.bounds.width, pdf.bounds.height],
337
- 'FF0000', '0000FF'
341
+ 'FF0000',
342
+ '0000FF'
338
343
  )
339
344
 
340
345
  str = pdf.render
@@ -391,9 +396,12 @@ describe Prawn::Graphics do
391
396
  describe 'radial gradients' do
392
397
  it 'creates a /Pattern resource' do
393
398
  pdf.fill_gradient(
394
- [0, pdf.bounds.height], 10,
395
- [pdf.bounds.width, pdf.bounds.height], 20,
396
- 'FF0000', '0000FF'
399
+ [0, pdf.bounds.height],
400
+ 10,
401
+ [pdf.bounds.width, pdf.bounds.height],
402
+ 20,
403
+ 'FF0000',
404
+ '0000FF'
397
405
  )
398
406
 
399
407
  grad = PDF::Inspector::Graphics::Pattern.analyze(pdf.render)
@@ -413,9 +421,12 @@ describe Prawn::Graphics do
413
421
 
414
422
  it 'fill_gradient should set fill color to the pattern' do
415
423
  pdf.fill_gradient(
416
- [0, pdf.bounds.height], 10,
417
- [pdf.bounds.width, pdf.bounds.height], 20,
418
- 'FF0000', '0000FF'
424
+ [0, pdf.bounds.height],
425
+ 10,
426
+ [pdf.bounds.width, pdf.bounds.height],
427
+ 20,
428
+ 'FF0000',
429
+ '0000FF'
419
430
  )
420
431
 
421
432
  str = pdf.render
@@ -424,9 +435,12 @@ describe Prawn::Graphics do
424
435
 
425
436
  it 'stroke_gradient should set stroke color to the pattern' do
426
437
  pdf.stroke_gradient(
427
- [0, pdf.bounds.height], 10,
428
- [pdf.bounds.width, pdf.bounds.height], 20,
429
- 'FF0000', '0000FF'
438
+ [0, pdf.bounds.height],
439
+ 10,
440
+ [pdf.bounds.width, pdf.bounds.height],
441
+ 20,
442
+ 'FF0000',
443
+ '0000FF'
430
444
  )
431
445
 
432
446
  str = pdf.render
@@ -438,9 +452,8 @@ describe Prawn::Graphics do
438
452
  subject(:transformations) do
439
453
  pdf.scale 2 do
440
454
  pdf.translate 40, 40 do
441
- pdf.fill_gradient [0, 10], [15, 15], 'FF0000', '0000FF', opts
442
- pdf.fill_gradient [0, 10], 15, [15, 15], 25, 'FF0000', '0000FF',
443
- opts
455
+ pdf.fill_gradient [0, 10], [15, 15], 'FF0000', '0000FF', **opts
456
+ pdf.fill_gradient [0, 10], 15, [15, 15], 25, 'FF0000', '0000FF', **opts
444
457
  end
445
458
  end
446
459
 
@@ -560,7 +573,7 @@ describe Prawn::Graphics do
560
573
 
561
574
  it 'rounds dash values to four decimal places' do
562
575
  pdf.dash 5.12345
563
- expect(pdf.graphic_state.dash_setting).to eq('[5.1235 5.1235] 0.0 d')
576
+ expect(pdf.graphic_state.dash_setting).to eq('[5.12345 5.12345] 0.0 d')
564
577
  end
565
578
 
566
579
  it 'raises an error when dash is called w. a zero length or space' do
@@ -632,8 +645,8 @@ describe Prawn::Graphics do
632
645
  new_state = PDF::Core::GraphicState.new(pdf.graphic_state)
633
646
 
634
647
  %i[color_space dash fill_color stroke_color].each do |attr|
635
- expect(new_state.send(attr)).to eq(pdf.graphic_state.send(attr))
636
- expect(new_state.send(attr)).to_not equal(pdf.graphic_state.send(attr))
648
+ expect(new_state.public_send(attr)).to eq(pdf.graphic_state.public_send(attr))
649
+ expect(new_state.public_send(attr)).to_not equal(pdf.graphic_state.public_send(attr))
637
650
  end
638
651
  end
639
652
 
@@ -641,14 +654,14 @@ describe Prawn::Graphics do
641
654
  new_state = pdf.graphic_state.dup
642
655
 
643
656
  %i[color_space dash fill_color stroke_color].each do |attr|
644
- expect(new_state.send(attr)).to eq(pdf.graphic_state.send(attr))
645
- expect(new_state.send(attr)).to_not equal(pdf.graphic_state.send(attr))
657
+ expect(new_state.public_send(attr)).to eq(pdf.graphic_state.public_send(attr))
658
+ expect(new_state.public_send(attr)).to_not equal(pdf.graphic_state.public_send(attr))
646
659
  end
647
660
  end
648
661
  end
649
662
 
650
663
  describe 'When using transformation matrix' do
651
- # Note: The (approximate) number of significant decimal digits of precision
664
+ # NOTE: The (approximate) number of significant decimal digits of precision
652
665
  # in fractional part is 5 (PDF Reference, Third Edition, p. 706)
653
666
 
654
667
  it 'sends the right content on transformation_matrix' do
@@ -694,17 +707,24 @@ describe Prawn::Graphics do
694
707
  expect(pdf).to have_received(:restore_graphics_state).with(no_args)
695
708
  .ordered
696
709
  end
710
+
711
+ it 'properly serializes the matrix', issue: 1178 do
712
+ pdf.transformation_matrix 1, 0, 0, 1, 0.0, 1.8977874316715393e-05
713
+ rendered_document = pdf.render
714
+
715
+ expect(rendered_document).to_not include('2.0e-05')
716
+
717
+ matrices = PDF::Inspector::Graphics::Matrix.analyze(rendered_document)
718
+ expect(matrices.matrices).to eq([[1, 0, 0, 1, 0.0, 0.00002]])
719
+ end
697
720
  end
698
721
 
699
722
  describe 'When using transformations shortcuts' do
700
- let(:x) { 12 }
701
- let(:y) { 54.32 }
702
- let(:angle) { 12.32 }
703
- let(:cos) { Math.cos(angle * Math::PI / 180) }
704
- let(:sin) { Math.sin(angle * Math::PI / 180) }
705
- let(:factor) { 0.12 }
706
-
707
723
  describe '#rotate' do
724
+ let(:angle) { 12.32 }
725
+ let(:cos) { Math.cos(angle * Math::PI / 180) }
726
+ let(:sin) { Math.sin(angle * Math::PI / 180) }
727
+
708
728
  it 'rotates' do
709
729
  allow(pdf).to receive(:transformation_matrix)
710
730
  .with(cos, sin, -sin, cos, 0, 0)
@@ -715,7 +735,13 @@ describe Prawn::Graphics do
715
735
  end
716
736
 
717
737
  describe '#rotate with :origin option' do
738
+ let(:angle) { 12.32 }
739
+ let(:cos) { Math.cos(angle * Math::PI / 180) }
740
+ let(:sin) { Math.sin(angle * Math::PI / 180) }
741
+
718
742
  it 'rotates around the origin' do
743
+ x = 12
744
+ y = 54.32
719
745
  x_prime = x * cos - y * sin
720
746
  y_prime = x * sin + y * cos
721
747
 
@@ -737,6 +763,8 @@ describe Prawn::Graphics do
737
763
  end
738
764
 
739
765
  it 'rotates around the origin in a document with a margin' do
766
+ x = 12
767
+ y = 54.32
740
768
  pdf = Prawn::Document.new
741
769
 
742
770
  pdf.rotate(angle, origin: [x, y]) { pdf.text('hello world') }
@@ -763,7 +791,7 @@ describe Prawn::Graphics do
763
791
 
764
792
  it 'raise_errors BlockRequired if no block is given' do
765
793
  expect do
766
- pdf.rotate(angle, origin: [x, y])
794
+ pdf.rotate(angle, origin: [0, 0])
767
795
  end.to raise_error(Prawn::Errors::BlockRequired)
768
796
  end
769
797
  end
@@ -781,6 +809,7 @@ describe Prawn::Graphics do
781
809
 
782
810
  describe '#scale' do
783
811
  it 'scales' do
812
+ factor = 0.12
784
813
  allow(pdf).to receive(:transformation_matrix)
785
814
  .with(factor, 0, 0, factor, 0, 0)
786
815
  pdf.scale(factor)
@@ -790,7 +819,11 @@ describe Prawn::Graphics do
790
819
  end
791
820
 
792
821
  describe '#scale with :origin option' do
822
+ let(:factor) { 0.12 }
823
+
793
824
  it 'scales from the origin' do
825
+ x = 12
826
+ y = 54.32
794
827
  x_prime = factor * x
795
828
  y_prime = factor * y
796
829
 
@@ -806,6 +839,8 @@ describe Prawn::Graphics do
806
839
  end
807
840
 
808
841
  it 'scales from the origin in a document with a margin' do
842
+ x = 12
843
+ y = 54.32
809
844
  pdf = Prawn::Document.new
810
845
  x_ = x + pdf.bounds.absolute_left
811
846
  y_ = y + pdf.bounds.absolute_bottom
@@ -825,7 +860,7 @@ describe Prawn::Graphics do
825
860
 
826
861
  it 'raise_errors BlockRequired if no block is given' do
827
862
  expect do
828
- pdf.scale(factor, origin: [x, y])
863
+ pdf.scale(factor, origin: [0, 0])
829
864
  end.to raise_error(Prawn::Errors::BlockRequired)
830
865
  end
831
866
  end