Sha256: c2ac9c2a3988644483a20013d320a37726452fb194395af8d42cee6ed4ec28c1

Contents?: true

Size: 1.07 KB

Versions: 13

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

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

      describe "#initialize" do
        let(:digested_key) do
          ::Armor.digest('cake', 'salt')
        end

        its(:key) { should == digested_key }
        specify { expect { AesNew.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 }
      end

      describe "#decrypt" do
        let(:decrypted) do
          subject.decrypt "V02ebRU2wLk25AizasROVg==$kE+IpRaUNdBfYqR+WjMqvA=="
        end

        specify { decrypted.should == 'string' }
      end

      describe "#search" do
        let(:records) do
          [{ name: 'Bob' }, { name: 'Tim' }]
        end

        it "finds the matching record" do
          expect(subject.search(records, :name, 'Bob')).to eql([records.first])
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
crypt_keeper-0.22.0 spec/provider/aes_new_spec.rb
crypt_keeper-0.21.0 spec/provider/aes_new_spec.rb
crypt_keeper-0.20.0 spec/provider/aes_new_spec.rb
crypt_keeper-0.19.0 spec/provider/aes_new_spec.rb
crypt_keeper-0.18.4 spec/provider/aes_new_spec.rb
crypt_keeper-0.18.3 spec/provider/aes_new_spec.rb
crypt_keeper-0.18.2 spec/provider/aes_new_spec.rb
crypt_keeper-0.18.1 spec/provider/aes_new_spec.rb
crypt_keeper-0.18.0 spec/provider/aes_new_spec.rb
crypt_keeper-0.17.0 spec/provider/aes_new_spec.rb
crypt_keeper-0.16.1 spec/provider/aes_new_spec.rb
crypt_keeper-0.16.0 spec/provider/aes_new_spec.rb
crypt_keeper-0.16.0.pre spec/provider/aes_new_spec.rb