Sha256: e9a1a7403300e879b0b98e03367f39fae92e02929ff43aa0a29d7fe7a970691c

Contents?: true

Size: 997 Bytes

Versions: 5

Compression:

Stored size: 997 Bytes

Contents

require 'spec_helper'

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

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

    specify { expect(subject.key).to eq(digested_key) }
    specify { expect { described_class.new }.to raise_error(ArgumentError, "Missing :key") }
  end

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

    specify { expect(encrypted).to_not eq('string') }
    specify { expect(encrypted).to_not be_blank }
  end

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

    specify { expect(decrypted).to eq('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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
crypt_keeper-1.1.1 spec/crypt_keeper/provider/aes_new_spec.rb
crypt_keeper-1.1.0 spec/crypt_keeper/provider/aes_new_spec.rb
crypt_keeper-1.0.1 spec/crypt_keeper/provider/aes_new_spec.rb
crypt_keeper-1.0.0 spec/crypt_keeper/provider/aes_new_spec.rb
crypt_keeper-1.0.0.beta1 spec/crypt_keeper/provider/aes_new_spec.rb