Skip to content

Commit

Permalink
Refactored empty string encryption/decryption test
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Apr 29, 2024
1 parent 627e59d commit 218f120
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions spec/unit/util/crypto_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,26 @@

context 'encrypts & decrypt' do
let(:string) { random_str }
let(:empty_string) { '' }

specify '#encrypts and decrypts a string' do
expect(string).to be_ascii_only
encrypted = subject.encrypt(string)
expect(subject.decrypt(encrypted)).to eql(string)
expect(encrypted).to be_truthy
decrypted = subject.decrypt(encrypted)
expect(decrypted).to eql(string)
expect(decrypted).to be_ascii_only
end

end

context 'encrypting an empty string' do
let(:empty_string) { '' }

it 'raises an ArgumentError' do
expect { subject.encrypt(empty_string) }.to raise_error ArgumentError, /data must not be empty/
specify '#encrypts and decrypts an empty string' do
expect(empty_string).to be_ascii_only
encrypted = subject.encrypt(empty_string)
expect(encrypted).to be_truthy
decrypted = subject.decrypt(encrypted)
expect(decrypted).to eql(empty_string)
expect(decrypted).to be_ascii_only
end

end

context 'using shared client lib fixture data' do
Expand Down

0 comments on commit 218f120

Please sign in to comment.