Sha256: f5653dbfdd37c414e166259ca4f65e282fa6f6fd0963380a2d8225194e964db1

Contents?: true

Size: 952 Bytes

Versions: 2

Compression:

Stored size: 952 Bytes

Contents

require 'spec_helper'
require 'active_record/pgcrypto/symmetric_coder'

RSpec.describe ActiveRecord::PGCrypto::SymmetricCoder do
  let(:pgcrypto_key) { FFaker::Internet.password }
  let(:text) { '€n©őđ3Đ' }
  let(:numeric) { rand(1.0..5.0) }

  before do
    described_class.pgcrypto_key = pgcrypto_key
  end

  it { expect(described_class.pgcrypto_key).to eq(pgcrypto_key) }

  context 'with encrypted text' do
    it { expect(described_class.dump(text)).not_to eq(text) }

    it { expect(described_class.dump(text)).not_to be_blank }

    it do
      expect(described_class.load(described_class.dump(text))).to eq(text)
    end
  end

  context 'with encrypted numeric' do
    it { expect(described_class.dump(numeric)).not_to eq(numeric.to_s) }

    it { expect(described_class.dump(numeric)).not_to be_blank }

    it do
      expect(
        described_class.load(described_class.dump(numeric))
      ).to eq(numeric.to_s)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_record-pgcrypto-0.2.6 spec/active_record/pgcrypto/symmetric_coder_spec.rb
active_record-pgcrypto-0.2.5 spec/active_record/pgcrypto/symmetric_coder_spec.rb