Sha256: 383be8b9705603d993a544eab6c88c0e61cbbc58e684a22d682b9c8545175ec1

Contents?: true

Size: 1.46 KB

Versions: 18

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

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

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

        its(:key) { should == hexed_key }
        specify { expect { Aes.new }.to raise_error(ArgumentError, "Missing :key") }
      end

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

        specify { encrypted.should_not == 'string' }
        specify { encrypted.should_not be_blank }

        context "an empty string" do
          let(:encrypted) do
            subject.encrypt ''
          end

          specify { encrypted.should == '' }
        end

        context "a nil" do
          let(:encrypted) do
            subject.encrypt nil
          end

          specify { encrypted.should be_nil }
        end
      end

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

        specify { decrypted.should == 'string' }

        context "an empty string" do
          let(:decrypted) do
            subject.decrypt ''
          end

          specify { decrypted.should == '' }
        end

        context "a nil" do
          let(:decrypted) do
            subject.decrypt nil
          end

          specify { decrypted.should be_nil }
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
crypt_keeper-0.22.0 spec/provider/aes_spec.rb
crypt_keeper-0.21.0 spec/provider/aes_spec.rb
crypt_keeper-0.20.0 spec/provider/aes_spec.rb
crypt_keeper-0.19.0 spec/provider/aes_spec.rb
crypt_keeper-0.18.4 spec/provider/aes_spec.rb
crypt_keeper-0.18.3 spec/provider/aes_spec.rb
crypt_keeper-0.18.2 spec/provider/aes_spec.rb
crypt_keeper-0.18.1 spec/provider/aes_spec.rb
crypt_keeper-0.18.0 spec/provider/aes_spec.rb
crypt_keeper-0.17.0 spec/provider/aes_spec.rb
crypt_keeper-0.16.1 spec/provider/aes_spec.rb
crypt_keeper-0.16.0 spec/provider/aes_spec.rb
crypt_keeper-0.16.0.pre spec/provider/aes_spec.rb
crypt_keeper-0.13.1 spec/provider/aes_spec.rb
crypt_keeper-0.13.0 spec/provider/aes_spec.rb
crypt_keeper-0.12.0 spec/provider/aes_spec.rb
crypt_keeper-0.11.0 spec/provider/aes_spec.rb
crypt_keeper-0.10.0.pre spec/provider/aes_spec.rb