|
233 | 233 | end |
234 | 234 |
|
235 | 235 | it 'should detect centered paragraphs' do |
236 | | - @doc.paragraphs[5].aligned_center?.should be_false |
237 | | - @doc.paragraphs[6].aligned_center?.should be_true |
238 | | - @doc.paragraphs[7].aligned_center?.should be_false |
| 236 | + expect(@doc.paragraphs[5].aligned_center?).to eq(false) |
| 237 | + expect(@doc.paragraphs[6].aligned_center?).to eq(true) |
| 238 | + expect(@doc.paragraphs[7].aligned_center?).to eq(false) |
239 | 239 | end |
240 | 240 |
|
241 | 241 | it 'should detect left justified paragraphs' do |
242 | | - @doc.paragraphs[6].aligned_left?.should be_false |
243 | | - @doc.paragraphs[7].aligned_left?.should be_true |
244 | | - @doc.paragraphs[8].aligned_left?.should be_false |
| 242 | + expect(@doc.paragraphs[6].aligned_left?).to eq(false) |
| 243 | + expect(@doc.paragraphs[7].aligned_left?).to eq(true) |
| 244 | + expect(@doc.paragraphs[8].aligned_left?).to eq(false) |
245 | 245 | end |
246 | 246 |
|
247 | 247 | it 'should detect right justified paragraphs' do |
248 | | - @doc.paragraphs[7].aligned_right?.should be_false |
249 | | - @doc.paragraphs[8].aligned_right?.should be_true |
250 | | - @doc.paragraphs[9].aligned_right?.should be_false |
| 248 | + expect(@doc.paragraphs[7].aligned_right?).to eq(false) |
| 249 | + expect(@doc.paragraphs[8].aligned_right?).to eq(true) |
| 250 | + expect(@doc.paragraphs[9].aligned_right?).to eq(false) |
251 | 251 | end |
252 | 252 |
|
253 | 253 | # ECMA-376 Office Open XML spec (4th edition), 17.3.2.38, size is |
254 | 254 | # defined in half-points, meaning 14pt text returns a value of 28. |
255 | 255 | # http://www.ecma-international.org/publications/standards/Ecma-376.htm |
256 | 256 | it 'should return proper font size for paragraphs' do |
257 | | - @doc.font_size.should eq 11 |
258 | | - @doc.paragraphs[5].font_size.should eq 11 |
| 257 | + expect(@doc.font_size).to eq 11 |
| 258 | + expect(@doc.paragraphs[5].font_size).to eq 11 |
259 | 259 | paragraph = @doc.paragraphs[9] |
260 | | - paragraph.font_size.should eq 14 |
261 | | - paragraph.text_runs[0].font_size.should eq 14 |
| 260 | + expect(paragraph.font_size).to eq 14 |
| 261 | + expect(paragraph.text_runs[0].font_size).to eq 14 |
262 | 262 | end |
263 | 263 |
|
264 | 264 | it 'should return proper font size for runs' do |
265 | | - @doc.font_size.should eq 11 |
| 265 | + expect(@doc.font_size).to eq 11 |
266 | 266 | paragraph = @doc.paragraphs[10] |
267 | | - paragraph.font_size.should eq 11 |
| 267 | + expect(paragraph.font_size).to eq 11 |
268 | 268 | text_runs = paragraph.text_runs |
269 | | - text_runs[0].font_size.should eq 11 |
270 | | - text_runs[1].font_size.should eq 16 |
271 | | - text_runs[2].font_size.should eq 11 |
272 | | - text_runs[3].font_size.should eq 11 |
273 | | - text_runs[4].font_size.should eq 11 |
| 269 | + expect(text_runs[0].font_size).to eq 11 |
| 270 | + expect(text_runs[1].font_size).to eq 16 |
| 271 | + expect(text_runs[2].font_size).to eq 11 |
| 272 | + expect(text_runs[3].font_size).to eq 11 |
| 273 | + expect(text_runs[4].font_size).to eq 11 |
274 | 274 | end |
275 | 275 | end |
276 | 276 |
|
|
318 | 318 |
|
319 | 319 | it 'should wrap pragraphs in a p tag' do |
320 | 320 | scan = @doc.paragraphs[0].to_html.scan(@p_regex).flatten |
321 | | - scan.first.should eq '<p' |
322 | | - scan.last.should eq '</p>' |
323 | | - scan[1].should eq 'Normal' |
| 321 | + expect(scan.first).to eq('<p') |
| 322 | + expect(scan.last).to eq('</p>') |
| 323 | + expect(scan[1]).to eq('Normal') |
324 | 324 | end |
325 | 325 |
|
326 | 326 | it 'should emphasize italicized text' do |
327 | 327 | scan = @doc.paragraphs[1].to_html.scan(@em_regex).flatten |
328 | | - scan.first.should eq '<em' |
329 | | - scan.last.should eq '</em>' |
330 | | - scan[1].should eq 'Italic' |
| 328 | + expect(scan.first).to eq('<em') |
| 329 | + expect(scan.last).to eq('</em>') |
| 330 | + expect(scan[1]).to eq('Italic') |
331 | 331 | end |
332 | 332 |
|
333 | 333 | it 'should strong bolded text' do |
334 | 334 | scan = @doc.paragraphs[2].to_html.scan(@strong_regex).flatten |
335 | | - scan.first.should eq '<strong' |
336 | | - scan.last.should eq '</strong>' |
337 | | - scan[1].should eq 'Bold' |
| 335 | + expect(scan.first).to eq '<strong' |
| 336 | + expect(scan.last).to eq '</strong>' |
| 337 | + expect(scan[1]).to eq 'Bold' |
338 | 338 | end |
339 | 339 |
|
340 | 340 | it 'should underline underlined text' do |
341 | 341 | scan = @doc.paragraphs[3].to_html.scan(/\<span\s+([^\>]+)/).flatten |
342 | | - scan.first.should eq 'style="text-decoration:underline;"' |
| 342 | + expect(scan.first).to eq 'style="text-decoration:underline;"' |
343 | 343 | end |
344 | 344 |
|
345 | 345 | it 'should justify paragraphs' do |
346 | 346 | regex = /^<p[^\"]+.(?<=\")([^\"]+)/ |
347 | | - @doc.paragraphs[6].to_html.scan(regex).flatten.first.split(';').include?('text-align:center').should be_true |
348 | | - @doc.paragraphs[7].to_html.scan(regex).flatten.first.split(';').include?('text-align:left').should be_false |
349 | | - @doc.paragraphs[8].to_html.scan(regex).flatten.first.split(';').include?('text-align:right').should be_true |
| 347 | + expect(@doc.paragraphs[6].to_html.scan(regex).flatten.first.split(';').include?('text-align:center')).to eq(true) |
| 348 | + expect(@doc.paragraphs[7].to_html.scan(regex).flatten.first.split(';').include?('text-align:left')).to eq(false) |
| 349 | + expect(@doc.paragraphs[8].to_html.scan(regex).flatten.first.split(';').include?('text-align:right')).to eq(true) |
350 | 350 | end |
351 | 351 |
|
352 | 352 | it "should set font size on styled paragraphs" do |
353 | 353 | regex = /(\<p{1})[^\>]+style\=\"([^\"]+).+(<\/p>)/ |
354 | 354 | scan = @doc.paragraphs[9].to_html.scan(regex).flatten |
355 | | - scan.first.should eq '<p' |
356 | | - scan.last.should eq '</p>' |
357 | | - scan[1].split(';').include?('font-size:14pt').should be_true |
| 355 | + expect(scan.first).to eq '<p' |
| 356 | + expect(scan.last).to eq '</p>' |
| 357 | + expect(scan[1].split(';').include?('font-size:14pt')).to eq(true) |
358 | 358 | end |
359 | 359 |
|
360 | 360 | it 'should set font size on styled text runs' do |
361 | 361 | regex = /(\<span)[^\>]+style\=\"([^\"]+)[^\<]+(<\/span>)/ |
362 | 362 | scan = @doc.paragraphs[10].to_html.scan(regex).flatten |
363 | | - scan.first.should eq '<span' |
364 | | - scan.last.should eq '</span>' |
365 | | - scan[1].split(';').include?('font-size:16pt').should be_true |
| 363 | + expect(scan.first).to eq '<span' |
| 364 | + expect(scan.last).to eq '</span>' |
| 365 | + expect(scan[1].split(';').include?('font-size:16pt')).to eq(true) |
366 | 366 | end |
367 | 367 |
|
368 | 368 | it 'should properly highlight different text in different places in a sentence' do |
369 | 369 | paragraph = @doc.paragraphs[11] |
370 | 370 | scan = paragraph.to_html.scan(@em_regex).flatten |
371 | | - scan.first.should eq '<em' |
372 | | - scan.last.should eq '</em>' |
373 | | - scan[1].should eq 'sentence' |
| 371 | + expect(scan.first).to eq '<em' |
| 372 | + expect(scan.last).to eq '</em>' |
| 373 | + expect(scan[1]).to eq 'sentence' |
374 | 374 | scan = paragraph.to_html.scan(@strong_regex).flatten |
375 | | - scan.first.should eq '<strong' |
376 | | - scan.last.should eq '</strong>' |
377 | | - scan[1].should eq 'formatting' |
| 375 | + expect(scan.first).to eq '<strong' |
| 376 | + expect(scan.last).to eq '</strong>' |
| 377 | + expect(scan[1]).to eq 'formatting' |
378 | 378 | scan = paragraph.to_html.scan(@span_regex).flatten |
379 | | - scan.first.should eq '<span' |
380 | | - scan.last.should eq '</span>' |
381 | | - scan[1].should eq 'different' |
| 379 | + expect(scan.first).to eq '<span' |
| 380 | + expect(scan.last).to eq '</span>' |
| 381 | + expect(scan[1]).to eq 'different' |
382 | 382 | scan = paragraph.to_html.scan(/\<span\s+([^\>]+)/).flatten |
383 | | - scan.first.should eq 'style="text-decoration:underline;"' |
| 383 | + expect(scan.first).to eq 'style="text-decoration:underline;"' |
384 | 384 | end |
385 | 385 |
|
386 | 386 | it 'should output an entire document as html fragment' do |
387 | | - @doc.to_html.scan(/(\<p)/).flatten.size.should eq @formatting_line_count |
| 387 | + expect(@doc.to_html.scan(/(\<p)/).flatten.size).to eq(@formatting_line_count) |
388 | 388 | end |
389 | 389 |
|
390 | 390 | it 'should output styled html' do |
391 | | - @formatted_line.to_html.scan('<span style="text-decoration:underline;"><strong><em>all</em></strong></span>').size.should eq 1 |
| 391 | + expect(@formatted_line.to_html.scan('<span style="text-decoration:underline;"><strong><em>all</em></strong></span>').size).to eq 1 |
392 | 392 | end |
393 | 393 |
|
394 | 394 | end |
|
0 commit comments