Sha256: 8057e06324d8f06c5b78055fc5c8d5a73ae5dc89831d4f311f2977b08703c717

Contents?: true

Size: 749 Bytes

Versions: 3

Compression:

Stored size: 749 Bytes

Contents

# -*- encoding: utf-8 -*-
require 'spec_helper'

describe 'SHA with salt encryption' do
  let(:credential) { ShaWithSaltCredential.create(:email => 'john.smith@example.com', :password => 'this is a secret') }

  context "#to_s" do
    subject { "#{credential.password}" }
    it { should eq("f218935d0c4b9a5e6d5faae7bc6b6bd35f319cbe") }
  end

  context "'this is a secret'" do
    subject { credential.password }
    it { should be_encrypted }
    it { should eq('this is a secret') }
  end

  context "cipher" do
    subject { credential.password.cipher }
    it { should be_an_instance_of(EncryptedStrings::ShaCipher) }
  end

  context "use custom salt" do
    subject { credential.password.cipher.salt }
    it { should eq('admin') }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-encryptor-0.0.5 spec/sha_with_salt_encryption_spec.rb
mongoid-encryptor-0.0.4 spec/sha_with_salt_encryption_spec.rb
mongoid-encryptor-0.0.1 spec/sha_with_salt_encryption_spec.rb