Sha256: 065f6ea7b8d9ff8fb12b8ebbdd56567e60abb499ed5cdd1359935b7d07d2c178

Contents?: true

Size: 1.62 KB

Versions: 17

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'
require 'keyring'

include CocoaPodsKeys

describe KeyringLiberator do
  before(:each) do
    ENV['ARMyKey'] = 'Hello'
  end

  after(:each) do
    ENV['ARMyKey'] = nil
  end

  it 'can get keys from ENV' do
    keyring = Keyring.new('test', '/', ['ARMyKey'])
    expect(keyring.keychain_data).to eq('ARMyKey' => 'Hello')
  end

  it 'looks up keys from the OSXKeychain' do
    keyring = Keyring.new('test', '/', ['ARMyKey'])
    keyring.instance_variable_set(:@keychain, FakeKeychain.new('KeychainKey' => 'abcde'))
    expect(keyring.keychain_has_key?('KeychainKey')).to be_truthy
    expect(keyring.keychain_value('KeychainKey')).to eq('abcde')
    expect(keyring.keychain_has_key?('NotMyKey')).to be_falsey
  end

  it 'looks up keys from ENV' do
    keyring = Keyring.new('test', '/', ['ARMyKey'])
    ENV['EnvKey'] = '12345'
    keyring.instance_variable_set(:@keychain, FakeKeychain.new('KeychainKey' => 'abcde'))
    expect(keyring.keychain_has_key?('EnvKey')).to be_truthy
    expect(keyring.keychain_value('EnvKey')).to eq('12345')
    expect(keyring.keychain_has_key?('NotMyKey')).to be_falsey
  end

  it 'updates its list of keys' do
    keyring = Keyring.new('test', '/', ['NotMyKey'])
    ENV['EnvKey'] = '12345'
    keyring.instance_variable_set(:@keychain, FakeKeychain.new('KeychainKey' => 'abcde'))

    keyring.keychain_has_key?('KeychainKey')
    keyring.keychain_has_key?('EnvKey')
    keyring.keychain_has_key?('NotMyKey')

    expect(keyring.keys.include?('KeychainKey')).to be_truthy
    expect(keyring.keys.include?('EnvKey')).to be_truthy
    expect(keyring.keys.include?('NotMyKey')).to be_falsey
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
cocoapods-keys-2.2.1 spec/keyring_spec.rb
cocoapods-keys-2.2.0 spec/keyring_spec.rb
cocoapods-keys-2.1.0 spec/keyring_spec.rb
cocoapods-keys-2.0.7 spec/keyring_spec.rb
cocoapods-keys-2.0.6 spec/keyring_spec.rb
cocoapods-keys-2.0.5 spec/keyring_spec.rb
cocoapods-keys-2.0.4 spec/keyring_spec.rb
cocoapods-keys-2.0.3 spec/keyring_spec.rb
cocoapods-keys-2.0.2 spec/keyring_spec.rb
cocoapods-keys-2.0.1 spec/keyring_spec.rb
cocoapods-keys-2.0.0 spec/keyring_spec.rb
cocoapods-keys-1.7.0 spec/keyring_spec.rb
cocoapods-keys-1.6.1 spec/keyring_spec.rb
cocoapods-keys-1.6.0 spec/keyring_spec.rb
cocoapods-keys-1.5.2 spec/keyring_spec.rb
cocoapods-keys-1.5.1 spec/keyring_spec.rb
cocoapods-keys-1.5.0 spec/keyring_spec.rb