spec/prawn/stamp_spec.rb in prawn-2.2.2 vs spec/prawn/stamp_spec.rb in prawn-2.3.0

- old
+ new

@@ -1,10 +1,13 @@ +# frozen_string_literal: true + require 'spec_helper' describe Prawn::Stamp do describe 'create_stamp before any page is added' do let(:pdf) { Prawn::Document.new(skip_page_creation: true) } + it 'works with the font class' do # If anything goes wrong, Prawn::Errors::NotOnPage will be raised pdf.create_stamp('my_stamp') do pdf.font.height end @@ -33,20 +36,20 @@ end describe 'Document with a stamp' do let(:pdf) { create_pdf } - it 'should raise_error NameTaken error when attempt to create stamp ' \ - 'with same name as an existing stamp' do + it 'raises NameTaken error when attempt to create stamp with '\ + 'same name as an existing stamp' do pdf.create_stamp('MyStamp') expect do pdf.create_stamp('MyStamp') end.to raise_error(Prawn::Errors::NameTaken) end - it 'should raise_error InvalidName error when attempt to create ' \ - 'stamp with a blank name' do + it 'raises InvalidName error when attempt to create stamp with '\ + 'a blank name' do expect do pdf.create_stamp('') end.to raise_error(Prawn::Errors::InvalidName) end @@ -90,11 +93,12 @@ output = pdf.render objects = output.split('endobj') objects.each do |obj| - next unless obj =~ %r{/Type /Page$} + next unless %r{/Type /Page$}.match?(obj) + # The page object must contain the annotation reference # to render a clickable link expect(obj).to match(%r{^/Annots \[\d \d .\]$}) end end @@ -110,12 +114,12 @@ # resorting to string matching output = pdf.render objects = output.split('endobj') objects.each do |object| - if object =~ %r{/Type /Page$} + if %r{/Type /Page$}.match?(object) expect(object).to_not match(%r{/ExtGState}) - elsif object =~ %r{/Type /XObject$} + elsif %r{/Type /XObject$}.match?(object) expect(object).to match(%r{/ExtGState}) end end end