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
@@ -8,20 +8,20 @@ describe "A document's grid" do
8
8
 
9
9
  it "should allow definition of a grid" do
10
10
  @pdf.define_grid(:columns => 5, :rows => 8, :gutter => 0.1)
11
- @pdf.grid.columns.should == 5
12
- @pdf.grid.rows.should == 8
13
- @pdf.grid.gutter.should == 0.1
11
+ expect(@pdf.grid.columns).to eq(5)
12
+ expect(@pdf.grid.rows).to eq(8)
13
+ expect(@pdf.grid.gutter).to eq(0.1)
14
14
  end
15
15
 
16
16
  it "should allow re-definition of a grid" do
17
17
  @pdf.define_grid(:columns => 5, :rows => 8, :gutter => 0.1)
18
- @pdf.grid.columns.should == 5
19
- @pdf.grid.rows.should == 8
20
- @pdf.grid.gutter.should == 0.1
18
+ expect(@pdf.grid.columns).to eq(5)
19
+ expect(@pdf.grid.rows).to eq(8)
20
+ expect(@pdf.grid.gutter).to eq(0.1)
21
21
  @pdf.define_grid(:columns => 3, :rows => 6, :gutter => 0.1)
22
- @pdf.grid.columns.should == 3
23
- @pdf.grid.rows.should == 6
24
- @pdf.grid.gutter.should == 0.1
22
+ expect(@pdf.grid.columns).to eq(3)
23
+ expect(@pdf.grid.rows).to eq(6)
24
+ expect(@pdf.grid.gutter).to eq(0.1)
25
25
  end
26
26
 
27
27
  describe "when a grid is defined" do
@@ -37,49 +37,48 @@ describe "A document's grid" do
37
37
  end
38
38
 
39
39
  it "should compute the column width" do
40
- (@pdf.grid.column_width * @num_columns.to_f +
41
- @gutter * (@num_columns - 1).to_f).should == @pdf.bounds.width
40
+ expect(@pdf.grid.column_width * @num_columns.to_f +
41
+ @gutter * (@num_columns - 1).to_f).to eq(@pdf.bounds.width)
42
42
  end
43
43
 
44
44
  it "should compute the row height" do
45
- (@pdf.grid.row_height * @num_rows.to_f +
46
- @gutter * (@num_rows - 1).to_f).should == @pdf.bounds.height
45
+ expect(@pdf.grid.row_height * @num_rows.to_f +
46
+ @gutter * (@num_rows - 1).to_f).to eq(@pdf.bounds.height)
47
47
  end
48
48
 
49
49
  it "should give the edges of a grid box" do
50
50
  grid_width = (@pdf.bounds.width.to_f -
51
- (@gutter * (@num_columns - 1).to_f )) / @num_columns.to_f
51
+ (@gutter * (@num_columns - 1).to_f)) / @num_columns.to_f
52
52
  grid_height = (@pdf.bounds.height.to_f -
53
- (@gutter * (@num_rows - 1).to_f ))/ @num_rows.to_f
53
+ (@gutter * (@num_rows - 1).to_f)) / @num_rows.to_f
54
54
 
55
55
  exp_tl_x = (grid_width + @gutter.to_f) * 4.0
56
56
  exp_tl_y = @pdf.bounds.height.to_f - (grid_height + @gutter.to_f)
57
57
 
58
- @pdf.grid(1,4).top_left.should == [exp_tl_x, exp_tl_y]
59
- @pdf.grid(1,4).top_right.should == [exp_tl_x + grid_width, exp_tl_y]
60
- @pdf.grid(1,4).bottom_left.should == [exp_tl_x, exp_tl_y - grid_height]
61
- @pdf.grid(1,4).bottom_right.should == [exp_tl_x + grid_width, exp_tl_y - grid_height]
58
+ expect(@pdf.grid(1, 4).top_left).to eq([exp_tl_x, exp_tl_y])
59
+ expect(@pdf.grid(1, 4).top_right).to eq([exp_tl_x + grid_width, exp_tl_y])
60
+ expect(@pdf.grid(1, 4).bottom_left).to eq([exp_tl_x, exp_tl_y - grid_height])
61
+ expect(@pdf.grid(1, 4).bottom_right).to eq([exp_tl_x + grid_width, exp_tl_y - grid_height])
62
62
  end
63
63
 
64
64
  it "should give the edges of a multiple grid boxes" do
65
65
  # Hand verified. Cheating a bit. Don't tell.
66
- @pdf.grid([1,3], [2,5]).top_left.should == [330.0, 628.75]
67
- @pdf.grid([1,3], [2,5]).top_right.should == [650.0, 628.75]
68
- @pdf.grid([1,3], [2,5]).bottom_left.should == [330.0, 456.25]
69
- @pdf.grid([1,3], [2,5]).bottom_right.should == [650.0, 456.25]
66
+ expect(@pdf.grid([1, 3], [2, 5]).top_left).to eq([330.0, 628.75])
67
+ expect(@pdf.grid([1, 3], [2, 5]).top_right).to eq([650.0, 628.75])
68
+ expect(@pdf.grid([1, 3], [2, 5]).bottom_left).to eq([330.0, 456.25])
69
+ expect(@pdf.grid([1, 3], [2, 5]).bottom_right).to eq([650.0, 456.25])
70
70
  end
71
71
 
72
72
  it "should draw outlines without changing global default colors to grid color" do
73
73
  @pdf.grid.show_all('cccccc')
74
74
 
75
75
  colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render)
76
- colors.fill_color.should_not == [0.8,0.8,0.8]
77
- colors.stroke_color.should_not == [0.8,0.8,0.8]
76
+ expect(colors.fill_color).not_to eq([0.8, 0.8, 0.8])
77
+ expect(colors.stroke_color).not_to eq([0.8, 0.8, 0.8])
78
78
 
79
79
  # Hardcoded default color as I haven't been able to come up with a stable converter
80
80
  # between fill_color without lots code.
81
- #colors.fill_color.should == [0.0,0.0,0.0]
82
- colors.stroke_color.should == [0.0,0.0,0.0]
81
+ expect(colors.stroke_color).to eq([0.0, 0.0, 0.0])
83
82
  end
84
83
 
85
84
  it "should draw outlines without curent color settings" do
@@ -89,8 +88,8 @@ describe "A document's grid" do
89
88
  @pdf.grid.show_all
90
89
 
91
90
  colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render)
92
- colors.fill_color.should == [0.8,1.0,0.0]
93
- colors.stroke_color.should == [1.0,0.8,0.0]
91
+ expect(colors.fill_color).to eq([0.8, 1.0, 0.0])
92
+ expect(colors.stroke_color).to eq([1.0, 0.8, 0.0])
94
93
  end
95
94
  end
96
95
  end
@@ -15,7 +15,7 @@ describe "ImageHandler" do
15
15
  image_handler.register(handler_b)
16
16
 
17
17
  handler = image_handler.find("arbitrary blob")
18
- handler.should == handler_a
18
+ expect(handler).to eq(handler_a)
19
19
  end
20
20
 
21
21
  it "can prepend handlers" do
@@ -25,7 +25,7 @@ describe "ImageHandler" do
25
25
  image_handler.register!(handler_b)
26
26
 
27
27
  handler = image_handler.find("arbitrary blob")
28
- handler.should == handler_b
28
+ expect(handler).to eq(handler_b)
29
29
  end
30
30
 
31
31
  it "can unregister a handler" do
@@ -37,7 +37,7 @@ describe "ImageHandler" do
37
37
  image_handler.unregister(handler_a)
38
38
 
39
39
  handler = image_handler.find('arbitrary blob')
40
- handler.should == handler_b
40
+ expect(handler).to eq(handler_b)
41
41
  end
42
42
 
43
43
  it "raises an error when no matching handler is found" do
@@ -48,7 +48,6 @@ describe "ImageHandler" do
48
48
  image_handler.register(handler_b)
49
49
 
50
50
  expect { image_handler.find("arbitrary blob") }.
51
- to(raise_error(Prawn::Errors::UnsupportedImageType))
51
+ to(raise_error(Prawn::Errors::UnsupportedImageType))
52
52
  end
53
-
54
53
  end
@@ -5,37 +5,36 @@ require 'set'
5
5
  require 'pathname'
6
6
 
7
7
  describe "the image() function" do
8
-
9
8
  before(:each) do
10
9
  @filename = "#{Prawn::DATADIR}/images/pigs.jpg"
11
10
  create_pdf
12
11
  end
13
12
 
14
13
  it "should only embed an image once, even if it's added multiple times" do
15
- @pdf.image @filename, :at => [100,100]
16
- @pdf.image @filename, :at => [300,300]
14
+ @pdf.image @filename, :at => [100, 100]
15
+ @pdf.image @filename, :at => [300, 300]
17
16
 
18
17
  output = @pdf.render
19
18
  images = PDF::Inspector::XObject.analyze(output)
20
19
  # there should be 2 images in the page resources
21
- images.page_xobjects.first.size.should == 2
20
+ expect(images.page_xobjects.first.size).to eq(2)
22
21
  # but only 1 image xobject
23
- output.scan(/\/Type \/XObject/).size.should == 1
22
+ expect(output.scan(/\/Type \/XObject/).size).to eq(1)
24
23
  end
25
24
 
26
25
  it "should return the image info object" do
27
26
  info = @pdf.image(@filename)
28
27
 
29
- info.should be_a_kind_of(Prawn::Images::JPG)
28
+ expect(info).to be_a_kind_of(Prawn::Images::JPG)
30
29
 
31
- info.height.should == 453
30
+ expect(info.height).to eq(453)
32
31
  end
33
32
 
34
33
  it "should accept IO objects" do
35
34
  file = File.open(@filename, "rb")
36
35
  info = @pdf.image(file)
37
36
 
38
- info.height.should == 453
37
+ expect(info.height).to eq(453)
39
38
  end
40
39
 
41
40
  it "rewinds IO objects to be able to embed them multiply" do
@@ -43,12 +42,12 @@ describe "the image() function" do
43
42
 
44
43
  @pdf.image(file)
45
44
  info = @pdf.image(file)
46
- info.height.should == 453
45
+ expect(info.height).to eq(453)
47
46
  end
48
47
 
49
48
  it "should accept Pathname objects" do
50
49
  info = @pdf.image(Pathname.new(@filename))
51
- info.height.should == 453
50
+ expect(info.height).to eq(453)
52
51
  end
53
52
 
54
53
  context "setting the length of the bytestream" do
@@ -70,25 +69,25 @@ describe "the image() function" do
70
69
 
71
70
  it "should raise_error an UnsupportedImageType if passed a BMP" do
72
71
  filename = "#{Prawn::DATADIR}/images/tru256.bmp"
73
- lambda { @pdf.image filename, :at => [100,100] }.should raise_error(Prawn::Errors::UnsupportedImageType)
72
+ expect { @pdf.image filename, :at => [100, 100] }.to raise_error(Prawn::Errors::UnsupportedImageType)
74
73
  end
75
74
 
76
75
  it "should raise_error an UnsupportedImageType if passed an interlaced PNG" do
77
76
  filename = "#{Prawn::DATADIR}/images/dice_interlaced.png"
78
- lambda { @pdf.image filename, :at => [100,100] }.should raise_error(Prawn::Errors::UnsupportedImageType)
77
+ expect { @pdf.image filename, :at => [100, 100] }.to raise_error(Prawn::Errors::UnsupportedImageType)
79
78
  end
80
79
 
81
80
  it "should bump PDF version to 1.5 or greater on embedding 16-bit PNGs" do
82
81
  @pdf.image "#{Prawn::DATADIR}/images/16bit.png"
83
- @pdf.state.version.should >= 1.5
82
+ expect(@pdf.state.version).to be >= 1.5
84
83
  end
85
84
 
86
85
  it "should embed 16-bit alpha channels for 16-bit PNGs" do
87
86
  @pdf.image "#{Prawn::DATADIR}/images/16bit.png"
88
87
 
89
88
  output = @pdf.render
90
- output.should =~ /\/BitsPerComponent 16/
91
- output.should_not =~ /\/BitsPerComponent 8/
89
+ expect(output).to match(/\/BitsPerComponent 16/)
90
+ expect(output).not_to match(/\/BitsPerComponent 8/)
92
91
  end
93
92
 
94
93
  it "should flow an image to a new page if it will not fit on a page" do
@@ -96,10 +95,10 @@ describe "the image() function" do
96
95
  @pdf.image @filename, :fit => [600, 600]
97
96
  output = StringIO.new(@pdf.render, 'r+')
98
97
  hash = PDF::Reader::ObjectHash.new(output)
99
- pages = hash.values.find {|obj| obj.is_a?(Hash) && obj[:Type] == :Pages}[:Kids]
100
- pages.size.should == 2
101
- hash[pages[0]][:Resources][:XObject].keys.should == [:I1]
102
- hash[pages[1]][:Resources][:XObject].keys.should == [:I2]
98
+ pages = hash.values.find { |obj| obj.is_a?(Hash) && obj[:Type] == :Pages }[:Kids]
99
+ expect(pages.size).to eq(2)
100
+ expect(hash[pages[0]][:Resources][:XObject].keys).to eq([:I1])
101
+ expect(hash[pages[1]][:Resources][:XObject].keys).to eq([:I2])
103
102
  end
104
103
 
105
104
  it "should not flow an image to a new page if it will fit on one page" do
@@ -107,10 +106,11 @@ describe "the image() function" do
107
106
  @pdf.image @filename, :fit => [400, 400]
108
107
  output = StringIO.new(@pdf.render, 'r+')
109
108
  hash = PDF::Reader::ObjectHash.new(output)
110
- pages = hash.values.find {|obj| obj.is_a?(Hash) && obj[:Type] == :Pages}[:Kids]
111
- pages.size.should == 1
112
- Set.new(hash[pages[0]][:Resources][:XObject].keys).should ==
109
+ pages = hash.values.find { |obj| obj.is_a?(Hash) && obj[:Type] == :Pages }[:Kids]
110
+ expect(pages.size).to eq(1)
111
+ expect(Set.new(hash[pages[0]][:Resources][:XObject].keys)).to eq(
113
112
  Set.new([:I1, :I2])
113
+ )
114
114
  end
115
115
 
116
116
  it "should not start a new page just for a stretchy bounding box" do
@@ -122,32 +122,46 @@ describe "the image() function" do
122
122
 
123
123
  describe ":fit option" do
124
124
  it "should fit inside the defined constraints" do
125
- info = @pdf.image @filename, :fit => [100,400]
126
- info.scaled_width.should <= 100
127
- info.scaled_height.should <= 400
125
+ info = @pdf.image @filename, :fit => [100, 400]
126
+ expect(info.scaled_width).to be <= 100
127
+ expect(info.scaled_height).to be <= 400
128
128
 
129
- info = @pdf.image @filename, :fit => [400,100]
130
- info.scaled_width.should <= 400
131
- info.scaled_height.should <= 100
129
+ info = @pdf.image @filename, :fit => [400, 100]
130
+ expect(info.scaled_width).to be <= 400
131
+ expect(info.scaled_height).to be <= 100
132
132
 
133
- info = @pdf.image @filename, :fit => [604,453]
134
- info.scaled_width.should == 604
135
- info.scaled_height.should == 453
133
+ info = @pdf.image @filename, :fit => [604, 453]
134
+ expect(info.scaled_width).to eq(604)
135
+ expect(info.scaled_height).to eq(453)
136
136
  end
137
137
  it "should move text position" do
138
138
  @y = @pdf.y
139
- info = @pdf.image @filename, :fit => [100,400]
140
- @pdf.y.should < @y
139
+ info = @pdf.image @filename, :fit => [100, 400]
140
+ expect(@pdf.y).to be < @y
141
141
  end
142
142
  end
143
143
 
144
144
  describe ":at option" do
145
145
  it "should not move text position" do
146
146
  @y = @pdf.y
147
- info = @pdf.image @filename, :at => [100,400]
148
- @pdf.y.should == @y
147
+ info = @pdf.image @filename, :at => [100, 400]
148
+ expect(@pdf.y).to eq(@y)
149
149
  end
150
150
  end
151
151
 
152
- end
152
+ describe ":width option without :height option" do
153
+ it "scales the width and height" do
154
+ info = @pdf.image @filename, :width => 225
155
+ expect(info.scaled_height).to eq(168.75)
156
+ expect(info.scaled_width).to eq(225.0)
157
+ end
158
+ end
153
159
 
160
+ describe ":height option without :width option" do
161
+ it "scales the width and height" do
162
+ info = @pdf.image @filename, :height => 225
163
+ expect(info.scaled_height).to eq(225.0)
164
+ expect(info.scaled_width).to eq(300.0)
165
+ end
166
+ end
167
+ end
@@ -5,443 +5,442 @@ describe "Text::Formatted::Parser#format" do
5
5
  it "should handle sup" do
6
6
  string = "<sup>superscript</sup>"
7
7
  array = Prawn::Text::Formatted::Parser.format(string)
8
- array[0].should == { :text => "superscript",
9
- :styles => [:superscript],
10
- :color => nil,
11
- :link => nil,
12
- :anchor => nil,
13
- :local => nil,
14
- :font => nil,
15
- :size => nil,
16
- :character_spacing => nil }
8
+ expect(array[0]).to eq(:text => "superscript",
9
+ :styles => [:superscript],
10
+ :color => nil,
11
+ :link => nil,
12
+ :anchor => nil,
13
+ :local => nil,
14
+ :font => nil,
15
+ :size => nil,
16
+ :character_spacing => nil)
17
17
  end
18
18
  it "should handle sub" do
19
19
  string = "<sub>subscript</sub>"
20
20
  array = Prawn::Text::Formatted::Parser.format(string)
21
- array[0].should == { :text => "subscript",
22
- :styles => [:subscript],
23
- :color => nil,
24
- :link => nil,
25
- :anchor => nil,
26
- :local => nil,
27
- :font => nil,
28
- :size => nil,
29
- :character_spacing => nil }
21
+ expect(array[0]).to eq(:text => "subscript",
22
+ :styles => [:subscript],
23
+ :color => nil,
24
+ :link => nil,
25
+ :anchor => nil,
26
+ :local => nil,
27
+ :font => nil,
28
+ :size => nil,
29
+ :character_spacing => nil)
30
30
  end
31
31
  it "should handle rgb" do
32
32
  string = "<color rgb='#ff0000'>red text</color>"
33
33
  array = Prawn::Text::Formatted::Parser.format(string)
34
- array[0].should == { :text => "red text",
35
- :styles => [],
36
- :color => "ff0000",
37
- :link => nil,
38
- :anchor => nil,
39
- :local => nil,
40
- :font => nil,
41
- :size => nil,
42
- :character_spacing => nil }
34
+ expect(array[0]).to eq(:text => "red text",
35
+ :styles => [],
36
+ :color => "ff0000",
37
+ :link => nil,
38
+ :anchor => nil,
39
+ :local => nil,
40
+ :font => nil,
41
+ :size => nil,
42
+ :character_spacing => nil)
43
43
  end
44
44
  it "# should be optional in rgb" do
45
45
  string = "<color rgb='ff0000'>red text</color>"
46
46
  array = Prawn::Text::Formatted::Parser.format(string)
47
- array[0].should == { :text => "red text",
48
- :styles => [],
49
- :color => "ff0000",
50
- :link => nil,
51
- :anchor => nil,
52
- :local => nil,
53
- :font => nil,
54
- :size => nil,
55
- :character_spacing => nil }
47
+ expect(array[0]).to eq(:text => "red text",
48
+ :styles => [],
49
+ :color => "ff0000",
50
+ :link => nil,
51
+ :anchor => nil,
52
+ :local => nil,
53
+ :font => nil,
54
+ :size => nil,
55
+ :character_spacing => nil)
56
56
  end
57
57
  it "should handle cmyk" do
58
58
  string = "<color c='0' m='100' y='0' k='0'>magenta text</color>"
59
59
  array = Prawn::Text::Formatted::Parser.format(string)
60
- array[0].should == { :text => "magenta text",
61
- :styles => [],
62
- :color => [0, 100, 0, 0],
63
- :link => nil,
64
- :anchor => nil,
65
- :local => nil,
66
- :font => nil,
67
- :size => nil,
68
- :character_spacing => nil }
60
+ expect(array[0]).to eq(:text => "magenta text",
61
+ :styles => [],
62
+ :color => [0, 100, 0, 0],
63
+ :link => nil,
64
+ :anchor => nil,
65
+ :local => nil,
66
+ :font => nil,
67
+ :size => nil,
68
+ :character_spacing => nil)
69
69
  end
70
70
  it "should handle fonts" do
71
71
  string = "<font name='Courier'>Courier text</font>"
72
72
  array = Prawn::Text::Formatted::Parser.format(string)
73
- array[0].should == { :text => "Courier text",
74
- :styles => [],
75
- :color => nil,
76
- :link => nil,
77
- :anchor => nil,
78
- :local => nil,
79
- :font => "Courier",
80
- :size => nil,
81
- :character_spacing => nil }
73
+ expect(array[0]).to eq(:text => "Courier text",
74
+ :styles => [],
75
+ :color => nil,
76
+ :link => nil,
77
+ :anchor => nil,
78
+ :local => nil,
79
+ :font => "Courier",
80
+ :size => nil,
81
+ :character_spacing => nil)
82
82
  end
83
83
  it "should handle size" do
84
84
  string = "<font size='14'>14 point text</font>"
85
85
  array = Prawn::Text::Formatted::Parser.format(string)
86
- array[0].should == { :text => "14 point text",
87
- :styles => [],
88
- :color => nil,
89
- :link => nil,
90
- :anchor => nil,
91
- :local => nil,
92
- :font => nil,
93
- :size => 14,
94
- :character_spacing => nil }
86
+ expect(array[0]).to eq(:text => "14 point text",
87
+ :styles => [],
88
+ :color => nil,
89
+ :link => nil,
90
+ :anchor => nil,
91
+ :local => nil,
92
+ :font => nil,
93
+ :size => 14,
94
+ :character_spacing => nil)
95
95
  end
96
96
  it "should handle character_spacing" do
97
97
  string = "<font character_spacing='2.5'>extra character spacing</font>"
98
98
  array = Prawn::Text::Formatted::Parser.format(string)
99
- array[0].should == { :text => "extra character spacing",
100
- :styles => [],
101
- :color => nil,
102
- :link => nil,
103
- :anchor => nil,
104
- :local => nil,
105
- :font => nil,
106
- :size => nil,
107
- :character_spacing => 2.5 }
99
+ expect(array[0]).to eq(:text => "extra character spacing",
100
+ :styles => [],
101
+ :color => nil,
102
+ :link => nil,
103
+ :anchor => nil,
104
+ :local => nil,
105
+ :font => nil,
106
+ :size => nil,
107
+ :character_spacing => 2.5)
108
108
  end
109
109
  it "should handle links" do
110
110
  string = "<link href='http://example.com'>external link</link>"
111
111
  array = Prawn::Text::Formatted::Parser.format(string)
112
- array[0].should == { :text => "external link",
113
- :styles => [],
114
- :color => nil,
115
- :link => "http://example.com",
116
- :anchor => nil,
117
- :local => nil,
118
- :font => nil,
119
- :size => nil,
120
- :character_spacing => nil }
112
+ expect(array[0]).to eq(:text => "external link",
113
+ :styles => [],
114
+ :color => nil,
115
+ :link => "http://example.com",
116
+ :anchor => nil,
117
+ :local => nil,
118
+ :font => nil,
119
+ :size => nil,
120
+ :character_spacing => nil)
121
121
  end
122
122
  it "should handle local links" do
123
123
  string = "<link local='/home/example/foo.bar'>local link</link>"
124
124
  array = Prawn::Text::Formatted::Parser.format(string)
125
- array[0].should == { :text => "local link",
126
- :styles => [],
127
- :color => nil,
128
- :link => nil,
129
- :anchor => nil,
130
- :local => "/home/example/foo.bar",
131
- :font => nil,
132
- :size => nil,
133
- :character_spacing => nil }
125
+ expect(array[0]).to eq(:text => "local link",
126
+ :styles => [],
127
+ :color => nil,
128
+ :link => nil,
129
+ :anchor => nil,
130
+ :local => "/home/example/foo.bar",
131
+ :font => nil,
132
+ :size => nil,
133
+ :character_spacing => nil)
134
134
  end
135
135
  it "should handle anchors" do
136
136
  string = "<link anchor='ToC'>internal link</link>"
137
137
  array = Prawn::Text::Formatted::Parser.format(string)
138
- array[0].should == { :text => "internal link",
139
- :styles => [],
140
- :color => nil,
141
- :link => nil,
142
- :anchor => "ToC",
143
- :local => nil,
144
- :font => nil,
145
- :size => nil,
146
- :character_spacing => nil }
138
+ expect(array[0]).to eq(:text => "internal link",
139
+ :styles => [],
140
+ :color => nil,
141
+ :link => nil,
142
+ :anchor => "ToC",
143
+ :local => nil,
144
+ :font => nil,
145
+ :size => nil,
146
+ :character_spacing => nil)
147
147
  end
148
148
  it "should handle higher order characters properly" do
149
149
  string = "<b>©\n©</b>"
150
150
  array = Prawn::Text::Formatted::Parser.format(string)
151
- array[0].should == { :text => "©",
152
- :styles => [:bold],
153
- :color => nil,
154
- :link => nil,
155
- :anchor => nil,
156
- :local => nil,
157
- :font => nil,
158
- :size => nil,
159
- :character_spacing => nil }
160
- array[1].should == { :text => "\n",
161
- :styles => [:bold],
162
- :color => nil,
163
- :link => nil,
164
- :anchor => nil,
165
- :local => nil,
166
- :font => nil,
167
- :size => nil,
168
- :character_spacing => nil }
169
- array[2].should == { :text => "©",
170
- :styles => [:bold],
171
- :color => nil,
172
- :link => nil,
173
- :anchor => nil,
174
- :local => nil,
175
- :font => nil,
176
- :size => nil,
177
- :character_spacing => nil }
151
+ expect(array[0]).to eq(:text => "©",
152
+ :styles => [:bold],
153
+ :color => nil,
154
+ :link => nil,
155
+ :anchor => nil,
156
+ :local => nil,
157
+ :font => nil,
158
+ :size => nil,
159
+ :character_spacing => nil)
160
+ expect(array[1]).to eq(:text => "\n",
161
+ :styles => [:bold],
162
+ :color => nil,
163
+ :link => nil,
164
+ :anchor => nil,
165
+ :local => nil,
166
+ :font => nil,
167
+ :size => nil,
168
+ :character_spacing => nil)
169
+ expect(array[2]).to eq(:text => "©",
170
+ :styles => [:bold],
171
+ :color => nil,
172
+ :link => nil,
173
+ :anchor => nil,
174
+ :local => nil,
175
+ :font => nil,
176
+ :size => nil,
177
+ :character_spacing => nil)
178
178
  end
179
179
  it "should convert &lt; &gt;, and &amp; to <, >, and &, respectively" do
180
180
  string = "hello <b>&lt;, &gt;, and &amp;</b>"
181
181
  array = Prawn::Text::Formatted::Parser.format(string)
182
- array[1].should == { :text => "<, >, and &",
183
- :styles => [:bold],
184
- :color => nil,
185
- :link => nil,
186
- :anchor => nil,
187
- :local => nil,
188
- :font => nil,
189
- :size => nil,
190
- :character_spacing => nil }
182
+ expect(array[1]).to eq(:text => "<, >, and &",
183
+ :styles => [:bold],
184
+ :color => nil,
185
+ :link => nil,
186
+ :anchor => nil,
187
+ :local => nil,
188
+ :font => nil,
189
+ :size => nil,
190
+ :character_spacing => nil)
191
191
  end
192
192
  it "should handle double qoutes around tag attributes" do
193
193
  string = 'some <font size="14">sized</font> text'
194
194
  array = Prawn::Text::Formatted::Parser.format(string)
195
- array[1].should == { :text => "sized",
196
- :styles => [],
197
- :color => nil,
198
- :link => nil,
199
- :anchor => nil,
200
- :local => nil,
201
- :font => nil,
202
- :size => 14,
203
- :character_spacing => nil }
195
+ expect(array[1]).to eq(:text => "sized",
196
+ :styles => [],
197
+ :color => nil,
198
+ :link => nil,
199
+ :anchor => nil,
200
+ :local => nil,
201
+ :font => nil,
202
+ :size => 14,
203
+ :character_spacing => nil)
204
204
  end
205
205
  it "should handle single qoutes around tag attributes" do
206
206
  string = "some <font size='14'>sized</font> text"
207
207
  array = Prawn::Text::Formatted::Parser.format(string)
208
- array[1].should == { :text => "sized",
209
- :styles => [],
210
- :color => nil,
211
- :link => nil,
212
- :anchor => nil,
213
- :local => nil,
214
- :font => nil,
215
- :size => 14,
216
- :character_spacing => nil }
208
+ expect(array[1]).to eq(:text => "sized",
209
+ :styles => [],
210
+ :color => nil,
211
+ :link => nil,
212
+ :anchor => nil,
213
+ :local => nil,
214
+ :font => nil,
215
+ :size => 14,
216
+ :character_spacing => nil)
217
217
  end
218
218
  it "should construct a formatted text array from a string" do
219
219
  string = "hello <b>world\nhow <i>are</i></b> you?"
220
220
  array = Prawn::Text::Formatted::Parser.format(string)
221
221
 
222
- array[0].should == { :text => "hello ",
223
- :styles => [],
224
- :color => nil,
225
- :link => nil,
226
- :anchor => nil,
227
- :local => nil,
228
- :font => nil,
229
- :size => nil,
230
- :character_spacing => nil }
231
- array[1].should == { :text => "world",
232
- :styles => [:bold],
233
- :color => nil,
234
- :link => nil,
235
- :anchor => nil,
236
- :local => nil,
237
- :font => nil,
238
- :size => nil,
239
- :character_spacing => nil }
240
- array[2].should == { :text => "\n",
241
- :styles => [:bold],
242
- :color => nil,
243
- :link => nil,
244
- :anchor => nil,
245
- :local => nil,
246
- :font => nil,
247
- :size => nil,
248
- :character_spacing => nil }
249
- array[3].should == { :text => "how ",
250
- :styles => [:bold],
251
- :color => nil,
252
- :link => nil,
253
- :anchor => nil,
254
- :local => nil,
255
- :font => nil,
256
- :size => nil,
257
- :character_spacing => nil }
258
- array[4].should == { :text => "are",
259
- :styles => [:bold, :italic],
260
- :color => nil,
261
- :link => nil,
262
- :anchor => nil,
263
- :local => nil,
264
- :font => nil,
265
- :size => nil,
266
- :character_spacing => nil }
267
- array[5].should == { :text => " you?",
268
- :styles => [],
269
- :color => nil,
270
- :link => nil,
271
- :anchor => nil,
272
- :local => nil,
273
- :font => nil,
274
- :size => nil,
275
- :character_spacing => nil }
222
+ expect(array[0]).to eq(:text => "hello ",
223
+ :styles => [],
224
+ :color => nil,
225
+ :link => nil,
226
+ :anchor => nil,
227
+ :local => nil,
228
+ :font => nil,
229
+ :size => nil,
230
+ :character_spacing => nil)
231
+ expect(array[1]).to eq(:text => "world",
232
+ :styles => [:bold],
233
+ :color => nil,
234
+ :link => nil,
235
+ :anchor => nil,
236
+ :local => nil,
237
+ :font => nil,
238
+ :size => nil,
239
+ :character_spacing => nil)
240
+ expect(array[2]).to eq(:text => "\n",
241
+ :styles => [:bold],
242
+ :color => nil,
243
+ :link => nil,
244
+ :anchor => nil,
245
+ :local => nil,
246
+ :font => nil,
247
+ :size => nil,
248
+ :character_spacing => nil)
249
+ expect(array[3]).to eq(:text => "how ",
250
+ :styles => [:bold],
251
+ :color => nil,
252
+ :link => nil,
253
+ :anchor => nil,
254
+ :local => nil,
255
+ :font => nil,
256
+ :size => nil,
257
+ :character_spacing => nil)
258
+ expect(array[4]).to eq(:text => "are",
259
+ :styles => [:bold, :italic],
260
+ :color => nil,
261
+ :link => nil,
262
+ :anchor => nil,
263
+ :local => nil,
264
+ :font => nil,
265
+ :size => nil,
266
+ :character_spacing => nil)
267
+ expect(array[5]).to eq(:text => " you?",
268
+ :styles => [],
269
+ :color => nil,
270
+ :link => nil,
271
+ :anchor => nil,
272
+ :local => nil,
273
+ :font => nil,
274
+ :size => nil,
275
+ :character_spacing => nil)
276
276
  end
277
277
  it "should accept <strong> as an alternative to <b>" do
278
278
  string = "<strong>bold</strong> not bold"
279
279
  array = Prawn::Text::Formatted::Parser.format(string)
280
280
 
281
- array[0].should == { :text => "bold",
282
- :styles => [:bold],
283
- :color => nil,
284
- :link => nil,
285
- :anchor => nil,
286
- :local => nil,
287
- :font => nil,
288
- :size => nil,
289
- :character_spacing => nil }
290
- array[1].should == { :text => " not bold",
291
- :styles => [],
292
- :color => nil,
293
- :link => nil,
294
- :anchor => nil,
295
- :local => nil,
296
- :font => nil,
297
- :size => nil,
298
- :character_spacing => nil }
281
+ expect(array[0]).to eq(:text => "bold",
282
+ :styles => [:bold],
283
+ :color => nil,
284
+ :link => nil,
285
+ :anchor => nil,
286
+ :local => nil,
287
+ :font => nil,
288
+ :size => nil,
289
+ :character_spacing => nil)
290
+ expect(array[1]).to eq(:text => " not bold",
291
+ :styles => [],
292
+ :color => nil,
293
+ :link => nil,
294
+ :anchor => nil,
295
+ :local => nil,
296
+ :font => nil,
297
+ :size => nil,
298
+ :character_spacing => nil)
299
299
  end
300
300
  it "should accept <em> as an alternative to <i>" do
301
301
  string = "<em>italic</em> not italic"
302
302
  array = Prawn::Text::Formatted::Parser.format(string)
303
303
 
304
- array[0].should == { :text => "italic",
305
- :styles => [:italic],
306
- :color => nil,
307
- :link => nil,
308
- :anchor => nil,
309
- :local => nil,
310
- :font => nil,
311
- :size => nil,
312
- :character_spacing => nil }
313
- array[1].should == { :text => " not italic",
314
- :styles => [],
315
- :color => nil,
316
- :link => nil,
317
- :anchor => nil,
318
- :local => nil,
319
- :font => nil,
320
- :size => nil,
321
- :character_spacing => nil }
304
+ expect(array[0]).to eq(:text => "italic",
305
+ :styles => [:italic],
306
+ :color => nil,
307
+ :link => nil,
308
+ :anchor => nil,
309
+ :local => nil,
310
+ :font => nil,
311
+ :size => nil,
312
+ :character_spacing => nil)
313
+ expect(array[1]).to eq(:text => " not italic",
314
+ :styles => [],
315
+ :color => nil,
316
+ :link => nil,
317
+ :anchor => nil,
318
+ :local => nil,
319
+ :font => nil,
320
+ :size => nil,
321
+ :character_spacing => nil)
322
322
  end
323
323
  it "should accept <a> as an alternative to <link>" do
324
324
  string = "<a href='http://example.com'>link</a> not a link"
325
325
  array = Prawn::Text::Formatted::Parser.format(string)
326
326
 
327
- array[0].should == { :text => "link",
328
- :styles => [],
329
- :color => nil,
330
- :link => "http://example.com",
331
- :anchor => nil,
332
- :local => nil,
333
- :font => nil,
334
- :size => nil,
335
- :character_spacing => nil }
336
- array[1].should == { :text => " not a link",
337
- :styles => [],
338
- :color => nil,
339
- :link => nil,
340
- :anchor => nil,
341
- :local => nil,
342
- :font => nil,
343
- :size => nil,
344
- :character_spacing => nil }
327
+ expect(array[0]).to eq(:text => "link",
328
+ :styles => [],
329
+ :color => nil,
330
+ :link => "http://example.com",
331
+ :anchor => nil,
332
+ :local => nil,
333
+ :font => nil,
334
+ :size => nil,
335
+ :character_spacing => nil)
336
+ expect(array[1]).to eq(:text => " not a link",
337
+ :styles => [],
338
+ :color => nil,
339
+ :link => nil,
340
+ :anchor => nil,
341
+ :local => nil,
342
+ :font => nil,
343
+ :size => nil,
344
+ :character_spacing => nil)
345
345
  end
346
346
 
347
347
  it "should turn <br>, <br/> into newline" do
348
348
  array = Prawn::Text::Formatted::Parser.format("hello<br>big<br/>world")
349
- array.map { |frag| frag[:text] }.join.should == "hello\nbig\nworld"
349
+ expect(array.map { |frag| frag[:text] }.join).to eq("hello\nbig\nworld")
350
350
  end
351
351
  end
352
352
 
353
-
354
353
  describe "Text::Formatted::Parser#to_string" do
355
354
  it "should handle sup" do
356
355
  string = "<sup>superscript</sup>"
357
356
  array = [{ :text => "superscript",
358
- :styles => [:superscript],
359
- :color => nil,
360
- :link => nil,
361
- :anchor => nil,
362
- :local => nil,
363
- :font => nil,
364
- :size => nil,
365
- :character_spacing => nil }]
366
- Prawn::Text::Formatted::Parser.to_string(array).should == string
357
+ :styles => [:superscript],
358
+ :color => nil,
359
+ :link => nil,
360
+ :anchor => nil,
361
+ :local => nil,
362
+ :font => nil,
363
+ :size => nil,
364
+ :character_spacing => nil }]
365
+ expect(Prawn::Text::Formatted::Parser.to_string(array)).to eq(string)
367
366
  end
368
367
  it "should handle sub" do
369
368
  string = "<sub>subscript</sub>"
370
369
  array = [{ :text => "subscript",
371
- :styles => [:subscript],
372
- :color => nil,
373
- :link => nil,
374
- :anchor => nil,
375
- :local => nil,
376
- :font => nil,
377
- :size => nil,
378
- :character_spacing => nil }]
379
- Prawn::Text::Formatted::Parser.to_string(array).should == string
370
+ :styles => [:subscript],
371
+ :color => nil,
372
+ :link => nil,
373
+ :anchor => nil,
374
+ :local => nil,
375
+ :font => nil,
376
+ :size => nil,
377
+ :character_spacing => nil }]
378
+ expect(Prawn::Text::Formatted::Parser.to_string(array)).to eq(string)
380
379
  end
381
380
  it "should handle rgb" do
382
381
  string = "<color rgb='ff0000'>red text</color>"
383
382
  array = [{ :text => "red text",
384
- :styles => [],
385
- :color => "ff0000",
386
- :link => nil,
387
- :anchor => nil,
388
- :local => nil,
389
- :font => nil,
390
- :size => nil,
391
- :character_spacing => nil }]
392
- Prawn::Text::Formatted::Parser.to_string(array).should == string
383
+ :styles => [],
384
+ :color => "ff0000",
385
+ :link => nil,
386
+ :anchor => nil,
387
+ :local => nil,
388
+ :font => nil,
389
+ :size => nil,
390
+ :character_spacing => nil }]
391
+ expect(Prawn::Text::Formatted::Parser.to_string(array)).to eq(string)
393
392
  end
394
393
  it "should handle cmyk" do
395
394
  string = "<color c='0' m='100' y='0' k='0'>magenta text</color>"
396
395
  array = [{ :text => "magenta text",
397
- :styles => [],
398
- :color => [0, 100, 0, 0],
399
- :link => nil,
400
- :anchor => nil,
401
- :local => nil,
402
- :font => nil,
403
- :size => nil,
404
- :character_spacing => nil }]
405
- Prawn::Text::Formatted::Parser.to_string(array).should == string
396
+ :styles => [],
397
+ :color => [0, 100, 0, 0],
398
+ :link => nil,
399
+ :anchor => nil,
400
+ :local => nil,
401
+ :font => nil,
402
+ :size => nil,
403
+ :character_spacing => nil }]
404
+ expect(Prawn::Text::Formatted::Parser.to_string(array)).to eq(string)
406
405
  end
407
406
  it "should handle fonts" do
408
407
  string = "<font name='Courier'>Courier text</font>"
409
408
  array = [{ :text => "Courier text",
410
- :styles => [],
411
- :color => nil,
412
- :link => nil,
413
- :anchor => nil,
414
- :local => nil,
415
- :font => "Courier",
416
- :size => nil,
417
- :character_spacing => nil }]
418
- Prawn::Text::Formatted::Parser.to_string(array).should == string
409
+ :styles => [],
410
+ :color => nil,
411
+ :link => nil,
412
+ :anchor => nil,
413
+ :local => nil,
414
+ :font => "Courier",
415
+ :size => nil,
416
+ :character_spacing => nil }]
417
+ expect(Prawn::Text::Formatted::Parser.to_string(array)).to eq(string)
419
418
  end
420
419
  it "should handle size" do
421
420
  string = "<font size='14'>14 point text</font>"
422
421
  array = [{ :text => "14 point text",
423
- :styles => [],
424
- :color => nil,
425
- :link => nil,
426
- :anchor => nil,
427
- :local => nil,
428
- :font => nil,
429
- :size => 14,
430
- :character_spacing => nil }]
431
- Prawn::Text::Formatted::Parser.to_string(array).should == string
422
+ :styles => [],
423
+ :color => nil,
424
+ :link => nil,
425
+ :anchor => nil,
426
+ :local => nil,
427
+ :font => nil,
428
+ :size => 14,
429
+ :character_spacing => nil }]
430
+ expect(Prawn::Text::Formatted::Parser.to_string(array)).to eq(string)
432
431
  end
433
432
  it "should handle character spacing" do
434
433
  string = "<font character_spacing='2.5'>2.5 extra character spacing</font>"
435
434
  array = [{ :text => "2.5 extra character spacing",
436
- :styles => [],
437
- :color => nil,
438
- :link => nil,
439
- :anchor => nil,
440
- :local => nil,
441
- :font => nil,
442
- :size => nil,
443
- :character_spacing => 2.5 }]
444
- Prawn::Text::Formatted::Parser.to_string(array).should == string
435
+ :styles => [],
436
+ :color => nil,
437
+ :link => nil,
438
+ :anchor => nil,
439
+ :local => nil,
440
+ :font => nil,
441
+ :size => nil,
442
+ :character_spacing => 2.5 }]
443
+ expect(Prawn::Text::Formatted::Parser.to_string(array)).to eq(string)
445
444
  end
446
445
  it "should handle links" do
447
446
  array = [{ :text => "external link",
@@ -454,7 +453,7 @@ describe "Text::Formatted::Parser#to_string" do
454
453
  :size => nil,
455
454
  :character_spacing => nil }]
456
455
  string = "<link href='http://example.com'>external link</link>"
457
- Prawn::Text::Formatted::Parser.to_string(array).should == string
456
+ expect(Prawn::Text::Formatted::Parser.to_string(array)).to eq(string)
458
457
  end
459
458
  it "should handle anchors" do
460
459
  array = [{ :text => "internal link",
@@ -466,74 +465,79 @@ describe "Text::Formatted::Parser#to_string" do
466
465
  :size => nil,
467
466
  :character_spacing => nil }]
468
467
  string = "<link anchor='ToC'>internal link</link>"
469
- Prawn::Text::Formatted::Parser.to_string(array).should == string
468
+ expect(Prawn::Text::Formatted::Parser.to_string(array)).to eq(string)
470
469
  end
471
470
  it "should convert <, >, and & to &lt; &gt;, and &amp;, respectively" do
472
- array = [{ :text => "hello ",
473
- :styles => [],
474
- :color => nil,
475
- :link => nil,
476
- :font => nil,
477
- :size => nil,
478
- :character_spacing => nil },
479
- { :text => "<, >, and &",
480
- :styles => [:bold],
481
- :color => nil,
482
- :link => nil,
483
- :font => nil,
484
- :size => nil,
485
- :character_spacing => nil }]
471
+ array = [
472
+ {
473
+ :text => "hello ",
474
+ :styles => [],
475
+ :color => nil,
476
+ :link => nil,
477
+ :font => nil,
478
+ :size => nil,
479
+ :character_spacing => nil
480
+ },
481
+ {
482
+ :text => "<, >, and &",
483
+ :styles => [:bold],
484
+ :color => nil,
485
+ :link => nil,
486
+ :font => nil,
487
+ :size => nil,
488
+ :character_spacing => nil
489
+ }
490
+ ]
486
491
  string = "hello <b>&lt;, &gt;, and &amp;</b>"
487
- Prawn::Text::Formatted::Parser.to_string(array).should == string
492
+ expect(Prawn::Text::Formatted::Parser.to_string(array)).to eq(string)
488
493
  end
489
- it "should construct an HTML-esque string from a formatted" +
490
- " text array" do
494
+ it "should construct an HTML-esque string from a formatted text array" do
491
495
  array = [
492
- { :text => "hello ",
493
- :styles => [],
494
- :color => nil,
495
- :link => nil,
496
- :font => nil,
497
- :size => 14,
498
- :character_spacing => nil },
499
- { :text => "world",
500
- :styles => [:bold],
501
- :color => nil,
502
- :link => nil,
503
- :font => nil,
504
- :size => nil,
505
- :character_spacing => nil },
506
- { :text => "\n",
507
- :styles => [:bold],
508
- :color => nil,
509
- :link => nil,
510
- :font => nil,
511
- :size => nil,
512
- :character_spacing => nil },
513
- { :text => "how ",
514
- :styles => [:bold],
515
- :color => nil,
516
- :link => nil,
517
- :font => nil,
518
- :size => nil,
519
- :character_spacing => nil },
520
- { :text => "are",
521
- :styles => [:bold, :italic],
522
- :color => nil,
523
- :link => nil,
524
- :font => nil,
525
- :size => nil,
526
- :character_spacing => nil },
527
- { :text => " you?",
528
- :styles => [],
529
- :color => nil,
530
- :link => nil,
531
- :font => nil,
532
- :size => nil,
533
- :character_spacing => nil }
534
- ]
496
+ { :text => "hello ",
497
+ :styles => [],
498
+ :color => nil,
499
+ :link => nil,
500
+ :font => nil,
501
+ :size => 14,
502
+ :character_spacing => nil },
503
+ { :text => "world",
504
+ :styles => [:bold],
505
+ :color => nil,
506
+ :link => nil,
507
+ :font => nil,
508
+ :size => nil,
509
+ :character_spacing => nil },
510
+ { :text => "\n",
511
+ :styles => [:bold],
512
+ :color => nil,
513
+ :link => nil,
514
+ :font => nil,
515
+ :size => nil,
516
+ :character_spacing => nil },
517
+ { :text => "how ",
518
+ :styles => [:bold],
519
+ :color => nil,
520
+ :link => nil,
521
+ :font => nil,
522
+ :size => nil,
523
+ :character_spacing => nil },
524
+ { :text => "are",
525
+ :styles => [:bold, :italic],
526
+ :color => nil,
527
+ :link => nil,
528
+ :font => nil,
529
+ :size => nil,
530
+ :character_spacing => nil },
531
+ { :text => " you?",
532
+ :styles => [],
533
+ :color => nil,
534
+ :link => nil,
535
+ :font => nil,
536
+ :size => nil,
537
+ :character_spacing => nil }
538
+ ]
535
539
  string = "<font size='14'>hello </font><b>world</b><b>\n</b><b>how </b><b><i>are</i></b> you?"
536
- Prawn::Text::Formatted::Parser.to_string(array).should == string
540
+ expect(Prawn::Text::Formatted::Parser.to_string(array)).to eq(string)
537
541
  end
538
542
  end
539
543
 
@@ -544,14 +548,14 @@ describe "Text::Formatted::Parser#array_paragraphs" do
544
548
  { :text => "how" },
545
549
  { :text => "are" },
546
550
  { :text => "you" }]
547
- target = [[{ :text => "\n"}],
551
+ target = [[{ :text => "\n" }],
548
552
  [{ :text => "hello" }],
549
553
  [{ :text => "world" }],
550
- [{ :text => "\n"}],
554
+ [{ :text => "\n" }],
551
555
  [{ :text => "how" },
552
556
  { :text => "are" },
553
557
  { :text => "you" }]]
554
- Prawn::Text::Formatted::Parser.array_paragraphs(array).should == target
558
+ expect(Prawn::Text::Formatted::Parser.array_paragraphs(array)).to eq(target)
555
559
  end
556
560
 
557
561
  it "should work properly if ending in an empty paragraph" do
@@ -559,6 +563,6 @@ describe "Text::Formatted::Parser#array_paragraphs" do
559
563
  target = [[{ :text => "\n" }],
560
564
  [{ :text => "hello" }],
561
565
  [{ :text => "world" }]]
562
- Prawn::Text::Formatted::Parser.array_paragraphs(array).should == target
566
+ expect(Prawn::Text::Formatted::Parser.array_paragraphs(array)).to eq(target)
563
567
  end
564
568
  end