spec/prawn/document/security_spec.rb in prawn-2.2.2 vs spec/prawn/document/security_spec.rb in prawn-2.3.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'spec_helper' require 'tempfile' describe Prawn::Document::Security do describe 'Password padding' do @@ -15,30 +17,31 @@ it 'pads short passwords' do pw = 'abcd' padded = pad_password(pw) expect(padded.length).to eq(32) expect(padded).to eq( - pw + Prawn::Document::Security::PasswordPadding[0, 28] + pw + Prawn::Document::Security::PASSWORD_PADDING[0, 28] ) end it 'fullies pad null passwords' do pw = '' padded = pad_password(pw) expect(padded.length).to eq(32) - expect(padded).to eq(Prawn::Document::Security::PasswordPadding) + expect(padded).to eq(Prawn::Document::Security::PASSWORD_PADDING) end end describe 'Setting permissions' do def doc_with_permissions(permissions) pdf = Prawn::Document.new - class << pdf - # Make things easier to test - public :permissions_value - end + # Make things easier to test + pdf.singleton_class.send :public, :permissions_value + # class << pdf + # public :permissions_value + # end pdf.encrypt_document(permissions: permissions) pdf end @@ -88,20 +91,20 @@ ) end end it 'calculates the correct owner hash' do - expect(pdf.owner_password_hash.unpack('H*').first) + expect(pdf.owner_password_hash.unpack1('H*')) .to match(/^61CA855012/i) end it 'calculates the correct user hash' do - expect(pdf.user_password_hash.unpack('H*').first) + expect(pdf.user_password_hash.unpack1('H*')) .to match(/^6BC8C51031/i) end it 'calculates the correct user_encryption_key' do - expect(pdf.user_encryption_key.unpack('H*').first.upcase) + expect(pdf.user_encryption_key.unpack1('H*').upcase) .to eq('B100AB6429') end end describe 'encrypted_pdf_object' do