spec/parsel_spec.rb in parsel-0.2.0 vs spec/parsel_spec.rb in parsel-0.3.0

- old
+ new

@@ -13,6 +13,28 @@ end it 'returns false when decryption fails' do expect(Parsel.decrypt('abc', '123')).to be_falsy end + + it 'uses custom iv' do + iv = SecureRandom.hex(100) + encrypted = Parsel.encrypt(key, iv, 'hello') + + expect(Parsel.decrypt(key, iv, encrypted)).to eq('hello') + end + + it 'return false when decryption for custom iv fails' do + iv = SecureRandom.hex(100) + encrypted = Parsel.encrypt(key, iv, 'hello') + + expect(Parsel.decrypt(key, encrypted)).to be_falsy + end + + it 'changes global iv' do + iv = SecureRandom.hex(100) + Parsel.default_iv = iv + encrypted = Parsel.encrypt(key, 'hello') + + expect(Parsel.decrypt(key, iv, encrypted)).to eq('hello') + end end