Sha256: fb4f32e36fb6e826203bb4974a14b955b400f835e3cd9fa7acb575dd6460f90d

Contents?: true

Size: 969 Bytes

Versions: 1

Compression:

Stored size: 969 Bytes

Contents

require 'spec_helper'

describe ChefVault::Certificate do
  let(:item) { double(ChefVault::Item) }
  let(:cert) { ChefVault::Certificate.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("contents"){ "baz" }
  end

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

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

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

  describe 'decrypt_contents' do

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

      cert.decrypt_contents
    end

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

      cert.decrypt_contents.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/certificate_spec.rb