lib/submodules/ably-ruby/spec/unit/util/crypto_spec.rb in ably-rest-1.2.4 vs lib/submodules/ably-ruby/spec/unit/util/crypto_spec.rb in ably-rest-1.2.6
- old
+ new
@@ -70,29 +70,29 @@
expect(cipher_params.key_length).to eql(192)
end
end
end
- context 'encrypts & decrypt' do
+ context '#encrypt & #decrypt' do
let(:string) { random_str }
- let(:byte_array) { random_str.to_msgpack.unpack('C*') }
+ let(:empty_string) { '' }
- specify '#encrypt encrypts a string' do
+ specify 'encrypts and decrypts a non-empty 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
- specify '#decrypt decrypts a string' do
- encrypted = subject.encrypt(string)
- expect(subject.decrypt(encrypted)).to eql(string)
- 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
let(:resources_root) { File.expand_path('../../../../lib/submodules/ably-common/test-resources', __FILE__) }