Sha256: b6946bded075ed5ebf916e87094c6fb885f4b7adaf4a84ec30ecc5777b161bec

Contents?: true

Size: 1016 Bytes

Versions: 15

Compression:

Stored size: 1016 Bytes

Contents

RSpec.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
    it "given an 'id' parameter, returns its value" do
      expect(cert["id"]).to eq "bar"
    end
  end

  describe "decrypt_contents" do
    it "echoes warning" do
      expect(ChefVault::Log).to receive(:warn).with("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")

      expect(cert.decrypt_contents).to eq "baz"
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
chef-vault-3.4.0.pre.pre417 spec/chef-vault/certificate_spec.rb
chef-vault-3.3.0 spec/chef-vault/certificate_spec.rb
chef-vault-3.3.0.pre.pre415 spec/chef-vault/certificate_spec.rb
chef-vault-3.3.0.pre.pre416 spec/chef-vault/certificate_spec.rb
chef-vault-3.3.0.pre.pre414 spec/chef-vault/certificate_spec.rb
chef-vault-3.2.0.pre.pre408 spec/chef-vault/certificate_spec.rb
chef-vault-3.2.0.pre.pre407 spec/chef-vault/certificate_spec.rb
chef-vault-3.2.0 spec/chef-vault/certificate_spec.rb
chef-vault-3.1.0 spec/chef-vault/certificate_spec.rb
chef-vault-3.0.3 spec/chef-vault/certificate_spec.rb
chef-vault-3.0.2 spec/chef-vault/certificate_spec.rb
chef-vault-3.0.1 spec/chef-vault/certificate_spec.rb
chef-vault-3.0.0 spec/chef-vault/certificate_spec.rb
chef-vault-3.0.0.rc2 spec/chef-vault/certificate_spec.rb
chef-vault-3.0.0.rc1 spec/chef-vault/certificate_spec.rb