Sha256: a20562ed23409a5702fc48b072c626caff29e0001381e2609efbb4bf0761e93d
Contents?: true
Size: 1.74 KB
Versions: 5
Compression:
Stored size: 1.74 KB
Contents
require 'spec_helper' describe Heirloom do before do @logger_double = double 'logger', :info => true @logger_double.stub :info => true, :debug => true @config_double = double 'config' @config_double.stub :logger => @logger_double @tempfile_double = double 'tempfile', :path => '/path_to_encrypted_archive', :close! => true Tempfile.stub :new => @tempfile_double @file = Heirloom::Cipher::File.new :config => @config_double end it "should encrypt the given file" do @file.should_receive(:which).with('gpg').and_return true command = 'gpg --batch --yes -c --cipher-algo AES256 --passphrase mysecret --output /path_to_encrypted_archive /file 2>&1' @file.should_receive(:`).with command $?.stub :success? => true FileUtils.should_receive(:mv). with('/path_to_encrypted_archive', '/file') @file.encrypt_file(:file => '/file', :secret => 'mysecret').should be_true end it "should return false if gpg is not in the path" do @file.should_receive(:which).with('gpg').and_return false @logger_double.should_receive(:error) @file.encrypt_file(:file => '/file', :secret => 'mysecret').should be_false end it "should return false if gpg returns non zero code" do @file.should_receive(:which).with('gpg').and_return true @logger_double.should_receive(:error) command = 'gpg --batch --yes -c --cipher-algo AES256 --passphrase mysecret --output /path_to_encrypted_archive /file 2>&1' @file.should_receive(:`).with command $?.stub :success? => false @file.encrypt_file(:file => '/file', :secret => 'mysecret').should be_false end end
Version data entries
5 entries across 5 versions & 1 rubygems