spec/webtranslateit/safe/gpg_spec.rb in webtranslateit-safe-0.4.0 vs spec/webtranslateit/safe/gpg_spec.rb in webtranslateit-safe-0.4.1
- old
+ new
@@ -1,14 +1,14 @@
require 'spec_helper'
describe WebTranslateIt::Safe::Gpg do
def def_backup
{
- compressed: false,
- command: 'command',
- extension: '.foo',
- filename: 'qweqwe'
+ :compressed => false,
+ :command => 'command',
+ :extension => '.foo',
+ :filename => 'qweqwe'
}
end
def gpg(config = {}, backup = def_backup)
WebTranslateIt::Safe::Gpg.new(
@@ -20,127 +20,127 @@
after(:each) { WebTranslateIt::Safe::TmpFile.cleanup }
describe :process do
before(:each) do
- @gpg = gpg
- stub(@gpg).gpg_password_file { 'pwd-file' }
- stub(@gpg).pipe { '|gpg -BLAH' }
+ @gpg = gpg()
+ stub(@gpg).gpg_password_file {'pwd-file'}
+ stub(@gpg).pipe {'|gpg -BLAH'}
end
describe 'when active' do
before(:each) do
- stub(@gpg).active? { true }
+ stub(@gpg).active? {true}
end
- it 'adds .gpg extension' do
+ it 'should add .gpg extension' do
mock(@gpg.backup.extension) << '.gpg'
@gpg.process
end
- it 'adds command pipe' do
+ it 'should add command pipe' do
mock(@gpg.backup.command) << (/\|gpg -BLAH/)
@gpg.process
end
- it 'sets compressed' do
+ it 'should set compressed' do
mock(@gpg.backup).compressed = true
@gpg.process
end
end
describe 'when inactive' do
before(:each) do
- stub(@gpg).active? { false }
+ stub(@gpg).active? {false}
end
- it 'does not touch extension' do
+ it 'should not touch extension' do
dont_allow(@gpg.backup.extension) << anything
@gpg.process
end
- it 'does not touch command' do
+ it 'should not touch command' do
dont_allow(@gpg.backup.command) << anything
@gpg.process
end
- it 'does not touch compressed' do
+ it 'should not touch compressed' do
dont_allow(@gpg.backup).compressed = anything
@gpg.process
end
end
end
describe :active? do
describe 'with key' do
- it 'is true' do
- expect(gpg(gpg: {key: :foo})).to be_active
+ it 'should be true' do
+ expect(gpg(:gpg => {:key => :foo}).active?).to be_truthy
end
end
describe 'with password' do
- it 'is true' do
- expect(gpg(gpg: {password: :foo})).to be_active
+ it 'should be true' do
+ expect(gpg(:gpg => {:password => :foo}).active?).to be_truthy
end
end
describe 'without key & password' do
- it 'is false' do
- expect(gpg).not_to be_active
+ it 'should be false' do
+ expect(gpg.active?).to be_falsy
end
end
describe 'with key & password' do
- it 'raises RuntimeError' do
+ it 'should raise RuntimeError' do
lambda {
- gpg(gpg: {key: 'foo', password: 'bar'}).send :active?
+ gpg(:gpg => {:key => 'foo', :password => 'bar'}).send :active?
}.should raise_error(RuntimeError, "can't use both gpg password and pubkey")
end
end
end
describe :pipe do
describe 'with key' do
- def kgpg(extra = {})
- gpg({gpg: {key: 'foo', options: 'GPG-OPT'}.merge(extra), options: 'OPT'})
+ def kgpg(extra={})
+ gpg({:gpg => {:key => 'foo', :options => 'GPG-OPT'}.merge(extra), :options => 'OPT'})
end
- it 'does not call gpg_password_file' do
+ it 'should not call gpg_password_file' do
g = kgpg
dont_allow(g).gpg_password_file(anything)
g.send(:pipe)
end
- it "uses '-r' and :options" do
+ it "should use '-r' and :options" do
kgpg.send(:pipe).should == '|gpg GPG-OPT -e -r foo'
end
- it "uses the 'command' options" do
- kgpg(command: 'other-gpg').send(:pipe).should == '|other-gpg GPG-OPT -e -r foo'
+ it "should use the 'command' options" do
+ kgpg(:command => 'other-gpg').send(:pipe).should == '|other-gpg GPG-OPT -e -r foo'
end
end
describe 'with password' do
def pgpg(extra = {})
- returning(gpg({gpg: {password: 'bar', options: 'GPG-OPT'}.merge(extra), options: 'OPT'})) do |g|
- stub(g).gpg_password_file(anything) { 'pass-file' }
+ returning(gpg({:gpg => {:password => 'bar', :options => 'GPG-OPT'}.merge(extra), :options => 'OPT'})) do |g|
+ stub(g).gpg_password_file(anything) {'pass-file'}
end
end
- it "uses '--passphrase-file' and :options" do
+ it "should use '--passphrase-file' and :options" do
pgpg.send(:pipe).should == '|gpg GPG-OPT -c --passphrase-file pass-file'
end
- it "uses the 'command' options" do
- pgpg(command: 'other-gpg').send(:pipe).should == '|other-gpg GPG-OPT -c --passphrase-file pass-file'
+ it "should use the 'command' options" do
+ pgpg(:command => 'other-gpg').send(:pipe).should == '|other-gpg GPG-OPT -c --passphrase-file pass-file'
end
end
end
describe :gpg_password_file do
- it 'creates password file' do
+ it 'should create password file' do
file = gpg.send(:gpg_password_file, 'foo')
expect(File.exist?(file)).to be true
File.read(file).should == 'foo'
end
end