spec/keychain_spec.rb in ruby-keychain-0.1.0 vs spec/keychain_spec.rb in ruby-keychain-0.1.1
- old
+ new
@@ -1,8 +1,22 @@
require 'spec_helper'
describe Keychain do
+
+ describe 'user interaction' do
+ it 'should be true by default' do
+ Keychain.user_interaction_allowed?.should be_true
+ end
+
+ it 'should be changeable' do
+ Keychain.user_interaction_allowed = false
+ Keychain.user_interaction_allowed?.should be_false
+ Keychain.user_interaction_allowed = true
+ Keychain.user_interaction_allowed?.should be_true
+ end
+ end
+
describe 'default' do
it "should return the login keychain" do
Keychain.default.path.should == File.expand_path(File.join(ENV['HOME'], 'Library','Keychains', 'login.keychain'))
end
end
@@ -12,17 +26,25 @@
keychain = Keychain.open(File.join(ENV['HOME'], 'Library','Keychains', 'login.keychain'))
keychain.path.should == Keychain.default.path
end
end
- describe 'new' do
+ describe 'create' do
it 'should create the keychain' do
begin
keychain = Keychain.create(File.join(Dir.tmpdir, "other_keychain_spec_#{Time.now.to_i}_#{Time.now.usec}_#{rand(1000)}.keychain"),
'password');
File.exists?(keychain.path).should be_true
ensure
keychain.delete
+ end
+ end
+
+ context 'no password supplied' do
+ #we have to stub this out as it would trigger a dialog box prompting for a password
+ it 'should create a keychain by prompting the user' do
+ Sec.should_receive('SecKeychainCreate').with('akeychain', 0, nil, 1, nil,kind_of(FFI::Pointer)).and_return(0)
+ Keychain.create('akeychain')
end
end
end
describe 'exists?' do
\ No newline at end of file