summaryrefslogtreecommitdiff
path: root/spec/unit/dsl
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-08-19 14:59:43 -0700
committerClaire McQuin <claire@getchef.com>2014-08-22 11:59:32 -0700
commitf3450405e3411644baafa9e453cd64f23f269acd (patch)
tree7036d3ecd175e79570788ed36e458fa686065831 /spec/unit/dsl
parent3a2ffe5e703d4dc6dfd220c7960b9325b6c9ac24 (diff)
downloadchef-f3450405e3411644baafa9e453cd64f23f269acd.tar.gz
Fix stubs.
Diffstat (limited to 'spec/unit/dsl')
-rw-r--r--spec/unit/dsl/data_query_spec.rb33
1 files changed, 21 insertions, 12 deletions
diff --git a/spec/unit/dsl/data_query_spec.rb b/spec/unit/dsl/data_query_spec.rb
index 6ae4fd9724..2e16d3c21d 100644
--- a/spec/unit/dsl/data_query_spec.rb
+++ b/spec/unit/dsl/data_query_spec.rb
@@ -97,37 +97,46 @@ describe Chef::DSL::DataQuery do
item
end
- shared_examples_for "encryption detected" do |version|
+ before do
+ allow( Chef::DataBagItem ).to receive(:load).with(bag_name, item_name).and_return(item)
+ end
+
+ shared_examples_for "encryption detected" do
let(:encoded_data) do
Chef::Config[:data_bag_encrypt_version] = version_number
Chef::EncryptedDataBagItem.encrypt_data_bag_item(raw_data, default_secret)
end
before do
- allow( Chef::DataBagItem ).to receive(:load).with(bag_name, item_name).and_return(item)
allow( Chef::EncryptedDataBagItem ).to receive(:load_secret).and_return(default_secret)
end
- it "detects #{version} encrypted data bag items" do
+ it "detects encrypted data bag" do
expect( language ).to receive(encryptor_keys).at_least(:once).and_call_original
expect( Chef::Log ).to receive(:debug).with(/Data bag item looks encrypted/)
language.data_bag_item(bag_name, item_name)
end
end
- include_examples "encryption detected", "v1" do
- let(:version_number) { 1 }
- let(:encryptor_keys) { :version_1_encryptor_keys }
+ context "when encryption version is 1" do
+ include_examples "encryption detected" do
+ let(:version_number) { 1 }
+ let(:encryptor_keys) { :version_1_encryptor_keys }
+ end
end
- include_examples "encryption detected", "v2" do
- let(:version_number) { 2 }
- let(:encryptor_keys) { :version_2_encryptor_keys }
+ context "when encryption version is 2" do
+ include_examples "encryption detected" do
+ let(:version_number) { 2 }
+ let(:encryptor_keys) { :version_2_encryptor_keys }
+ end
end
- include_examples "encryption detected", "v3" do
- let(:version_number) { 3 }
- let(:encryptor_keys) { :version_3_encryptor_keys }
+ context "when encryption version is 3" do
+ include_examples "encryption detected", "v3" do
+ let(:version_number) { 3 }
+ let(:encryptor_keys) { :version_3_encryptor_keys }
+ end
end
shared_examples_for "an encrypted data bag item" do