Sha256: 3bd5f6feb4e3389943cd619c712e75a759e1f74b1e2c96a2717d49b612b9513e

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'
require 'base64'

def tmp_filename
  File.expand_path(File.join(File.dirname(__FILE__), '../../tmp/bar.rb'))
end

describe InlineEncryption::CLI do

  describe 'initialize' do

    let(:subject){ InlineEncryption::CLI.new }

    before :all do
      @default_key = OpenSSL::PKey::RSA.generate(2048)
      InlineEncryption.config[:key] = @default_key
    end

    it 'should encrypt' do
      InlineEncryption.should_receive(:encrypt).with('hello')

      subject.encrypt('hello')
    end

    it 'should require a file if passed' do
      subject = InlineEncryption::CLI.new(['foo'], [ '-r', 'foo.rb' ], {})

      subject.should_receive(:load_environment).with('foo.rb')

      subject.encrypt('foo')
    end

  end


  describe 'load_environment' do

    before :each do
      FileUtils.mkdir_p File.dirname(tmp_filename)
      File.open(tmp_filename, 'w') do |file|
        file.puts 'class FooForInlineEncryptionSpec; end'
      end
    end

    after :each do
      FileUtils.rm_f File.dirname(tmp_filename)
    end

    it 'should require the file' do
      subject.send(:load_environment, tmp_filename)
      expect{ FooForInlineEncryptionSpec }.not_to raise_error
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inline_encryption-1.0.0 spec/inline_encryption/cli_spec.rb