Sha256: 8b516009250516ab1917340a39e12206d09e9a1bac5321a272a373c58e2e2d54

Contents?: true

Size: 704 Bytes

Versions: 1

Compression:

Stored size: 704 Bytes

Contents

require 'spec_helper'
require 'securerandom'

describe Vinz::Crypto do
  let(:message) { {foo: 'bar'} }
  let(:key) { SecureRandom.hex(128) }
  subject { described_class.new(key) }

  describe 'when key is valid' do
    it 'encrypts and decrypts message' do
      encrypted = subject.encrypt(message)
      decrypted = subject.decrypt(encrypted)
      expect(decrypted).to eq(message)
    end
  end

  describe 'when key is invalid' do
    it 'raises an exception' do
      enc = described_class.new(SecureRandom.hex(128))
      encrypted = enc.encrypt(message)
      dec = described_class.new(SecureRandom.hex(128))

      expect { dec.decrypt(encrypted) }.to raise_error(Vinz::Error)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vinz-1.1.7 spec/vinz_crypto_spec.rb