Sha256: 204be2280ffaa9dd8d00c41590d2c7276a76a565447b979f40696e6fb0441d40

Contents?: true

Size: 997 Bytes

Versions: 4

Compression:

Stored size: 997 Bytes

Contents

require 'spec_helper'

module CryptKeeperProviders
  describe Aes do
    subject { Aes.new(key: 'cake') }

    describe "#initialize" do
      let(:hexed_key) do
        Digest::SHA256.digest('cake')
      end

      it "should extract the key and digest it" do
        subject.key.should == hexed_key
      end

      it "should raise an exception with a missing key" do
        expect { Aes.new }.to raise_error(ArgumentError, "Missing :key")
      end
    end

    describe "#encrypt" do
      let(:encrypted) do
        subject.encrypt 'string'
      end

      it "should encrypt the string" do
        encrypted.should_not == 'string'
        encrypted.should_not be_nil
        encrypted.should_not be_empty
      end
    end

    describe "#decrypt" do
      let(:decrypted) do
        subject.decrypt "MC41MDk5MjI2NjgxMDI1MDI2OmNyeXB0X2tlZXBlcjpPI/8dCqWXDMVj7Jqs\nuwf/\n"
      end

      it "should decrypt the string" do
        decrypted.should == 'string'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
crypt_keeper_providers-0.5.0 spec/aes_spec.rb
crypt_keeper_providers-0.4.0 spec/aes_spec.rb
crypt_keeper_providers-0.3.0 spec/aes_spec.rb
crypt_keeper_providers-0.2.0 spec/aes_spec.rb