Sha256: 291a434e56ad3251158679ec37a9adc2dec6dba0c47ebbdd674b5c55363bd91b

Contents?: true

Size: 948 Bytes

Versions: 1

Compression:

Stored size: 948 Bytes

Contents

require 'spec_helper'

describe ChefVault::User do
  let(:item) { double(ChefVault::Item) }
  let(:user) { ChefVault::User.new("foo", "bar") }

  before do
    allow(ChefVault::Item).to receive(:load).with("foo", "bar"){ item }
    allow(item).to receive(:[]).with("id"){ "bar" }
    allow(item).to receive(:[]).with("password"){ "baz" }
  end

  describe '#new' do
    it 'loads item' do
      expect(ChefVault::Item).to receive(:load).with("foo", "bar")

      ChefVault::User.new("foo", "bar")
    end
  end

  describe '#[]' do
    specify { user["id"].should eq "bar" }
  end

  describe 'decrypt_password' do

    it 'echoes warning' do
      STDOUT.should_receive(:puts).with("WARNING: This method is deprecated, please switch to item['value'] calls")

      user.decrypt_password
    end

    it 'returns items password' do
      expect(item).to receive(:[]).with("password")

      user.decrypt_password.should eq "baz"
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chef-vault-2.3.0 spec/chef-vault/user_spec.rb