Sha256: 634b279103f1fc3e707a821e5708c613980ceb185e957ba40dbd6c6e9579a83c

Contents?: true

Size: 976 Bytes

Versions: 1

Compression:

Stored size: 976 Bytes

Contents

require 'spec_helper'

describe Heirloom do
  before do
    @logger_mock = mock 'logger', :info => true
    @logger_mock.stub :info => true
    @config_mock = mock 'config'
    @config_mock.stub :logger => @logger_mock
    @tempfile_stub = stub 'tempfile', :path => '/path_to_encrypted_archive'
    Tempfile.stub :new => @tempfile_stub
    @aes_mock = mock 'aes'
    OpenSSL::Cipher::AES256.should_receive(:new).
                            with(:CBC).and_return @aes_mock
    @file = Heirloom::Cipher::File.new :config => @config_mock
  end

  it "should encrypt the given file" do
    @aes_mock.should_receive(:encrypt)
    @aes_mock.should_receive(:random_iv).and_return 'firstsixteenchar'
    @aes_mock.should_receive(:iv=).with 'firstsixteenchar'
    @aes_mock.should_receive(:key=).with 'mysecret'
    ::File.should_receive(:open)
    @file.encrypt_file(:file   => '/file',
                       :secret => 'mysecret').should == '/path_to_encrypted_archive'
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heirloom-0.5.0rc3 spec/cipher/file_spec.rb