summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-03-03 16:22:23 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-03-03 16:22:23 -0800
commit5fd3c2f8376d7264d8ca4f883c9dfc4fbfb9b0d3 (patch)
tree41d861f8d67a80b1c789357c81545517ea00bd0c /spec/unit
parent0b835a0a92509c5d9ad4123d320024da0005dac3 (diff)
downloadchef-5fd3c2f8376d7264d8ca4f883c9dfc4fbfb9b0d3.tar.gz
better chef+ruby rspec constraints
lets us use Gem::Dependency constraints directly as rspec constraints for matching Chef::Version and RUBY_VERSION. copies some magic sauce from bundler that does something similar
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/cookbook/metadata_spec.rb4
-rw-r--r--spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb2
-rw-r--r--spec/unit/encrypted_data_bag_item_spec.rb4
-rw-r--r--spec/unit/node_spec.rb2
-rw-r--r--spec/unit/policy_builder/expand_node_object_spec.rb2
-rw-r--r--spec/unit/provider/execute_spec.rb4
-rw-r--r--spec/unit/resource/chef_gem_spec.rb4
-rw-r--r--spec/unit/run_list/versioned_recipe_list_spec.rb2
8 files changed, 12 insertions, 12 deletions
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb
index 0107667fcd..6a6b34f397 100644
--- a/spec/unit/cookbook/metadata_spec.rb
+++ b/spec/unit/cookbook/metadata_spec.rb
@@ -308,7 +308,7 @@ describe Chef::Cookbook::Metadata do
end
end
- it "strips out self-dependencies", :chef_lt_13_only do
+ it "strips out self-dependencies", chef: "< 13" do
metadata.name("foo")
expect(Chef::Log).to receive(:warn).with(
"Ignoring self-dependency in cookbook foo, please remove it (in the future this will be fatal)."
@@ -317,7 +317,7 @@ describe Chef::Cookbook::Metadata do
expect(metadata.dependencies).to eql({})
end
- it "errors on self-dependencies", :chef_gte_13_only do
+ it "errors on self-dependencies", chef: ">= 13" do
metadata.name("foo")
expect { metadata.depends("foo") }.to raise_error
# FIXME: add the error type
diff --git a/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb b/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
index 685c2e738e..c2cb275f9d 100644
--- a/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
+++ b/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
@@ -83,7 +83,7 @@ describe Chef::EncryptedDataBagItem::CheckEncrypted do
end
end
- context "when encryption version is 3", :aes_256_gcm_only, :ruby_20_only do
+ context "when encryption version is 3", :aes_256_gcm_only, ruby: "~> 2.0.0" do
include_examples "encryption detected" do
let(:version) { 3 }
let(:encryptor) { Chef::EncryptedDataBagItem::Encryptor::Version3Encryptor }
diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb
index e3b77852b7..e17f7a2331 100644
--- a/spec/unit/encrypted_data_bag_item_spec.rb
+++ b/spec/unit/encrypted_data_bag_item_spec.rb
@@ -97,7 +97,7 @@ describe Chef::EncryptedDataBagItem::Encryptor do
Chef::Config[:data_bag_encrypt_version] = 3
end
- context "on supported platforms", :aes_256_gcm_only, :ruby_20_only do
+ context "on supported platforms", :aes_256_gcm_only, ruby: "~> 2.0.0" do
it "creates a version 3 encryptor" do
expect(encryptor).to be_a_instance_of(Chef::EncryptedDataBagItem::Encryptor::Version3Encryptor)
@@ -166,7 +166,7 @@ describe Chef::EncryptedDataBagItem::Decryptor do
context "when decrypting a version 3 (JSON+aes-256-gcm+random iv+auth tag) encrypted value" do
- context "on supported platforms", :aes_256_gcm_only, :ruby_20_only do
+ context "on supported platforms", :aes_256_gcm_only, ruby: "~> 2.0.0" do
let(:encrypted_value) do
Chef::EncryptedDataBagItem::Encryptor::Version3Encryptor.new(plaintext_data, encryption_key).for_encrypted_item
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 29f386aa7d..923b488f72 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -1511,7 +1511,7 @@ describe Chef::Node do
# added the policyfile attributes to the node JSON, therefore
# policyfile users need to be on 12.3 minimum when upgrading Chef
# Client to 13+
- it "lets the 400 pass through", :chef_gte_13_only do
+ it "lets the 400 pass through", chef: ">= 13" do
expect { node.save }.to raise_error(http_exception)
end
diff --git a/spec/unit/policy_builder/expand_node_object_spec.rb b/spec/unit/policy_builder/expand_node_object_spec.rb
index 8667532d72..420db2e855 100644
--- a/spec/unit/policy_builder/expand_node_object_spec.rb
+++ b/spec/unit/policy_builder/expand_node_object_spec.rb
@@ -38,7 +38,7 @@ describe Chef::PolicyBuilder::ExpandNodeObject do
expect(policy_builder).to respond_to(:load_node)
end
- it "has removed the deprecated #load_node method", :chef_gte_13_only do
+ it "has removed the deprecated #load_node method", chef: ">= 13" do
expect(policy_builder).to_not respond_to(:load_node)
end
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index c0646f2999..4b0afcb928 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -118,7 +118,7 @@ describe Chef::Provider::Execute do
new_resource.creates "foo_resource"
end
- it "should warn in Chef-12", :chef_lt_13_only do
+ it "should warn in Chef-12", chef: "< 13" do
expect(Chef::Log).to receive(:warn).with(/relative path/)
expect(FileTest).to receive(:exist?).with(new_resource.creates).and_return(true)
expect(provider).not_to receive(:shell_out!)
@@ -126,7 +126,7 @@ describe Chef::Provider::Execute do
expect(new_resource).not_to be_updated
end
- it "should raise if user specified relative path without cwd for Chef-13", :chef_gte_13_only do
+ it "should raise if user specified relative path without cwd for Chef-13", chef: ">= 13" do
expect(Chef::Log).to receive(:warn).with(/relative path/)
expect(FileTest).to receive(:exist?).with(new_resource.creates).and_return(true)
expect(provider).not_to receive(:shell_out!)
diff --git a/spec/unit/resource/chef_gem_spec.rb b/spec/unit/resource/chef_gem_spec.rb
index 0de9247196..c98b447582 100644
--- a/spec/unit/resource/chef_gem_spec.rb
+++ b/spec/unit/resource/chef_gem_spec.rb
@@ -70,14 +70,14 @@ describe Chef::Resource::ChefGem, "gem_binary" do
expect(Chef::Resource::ChefGem).to receive(:new).and_return(resource)
end
- it "runs the install at compile-time by default", :chef_lt_13_only do
+ it "runs the install at compile-time by default", chef: "< 13" do
expect(resource).to receive(:run_action).with(:install)
expect(Chef::Log).to receive(:deprecation).at_least(:once)
recipe.chef_gem "foo"
end
# the default behavior will change in Chef-13
- it "does not runs the install at compile-time by default", :chef_gte_13_only do
+ it "does not runs the install at compile-time by default", chef: ">= 13" do
expect(resource).not_to receive(:run_action).with(:install)
expect(Chef::Log).not_to receive(:deprecation)
recipe.chef_gem "foo"
diff --git a/spec/unit/run_list/versioned_recipe_list_spec.rb b/spec/unit/run_list/versioned_recipe_list_spec.rb
index 8bbd816956..91c601b294 100644
--- a/spec/unit/run_list/versioned_recipe_list_spec.rb
+++ b/spec/unit/run_list/versioned_recipe_list_spec.rb
@@ -186,7 +186,7 @@ describe Chef::RunList::VersionedRecipeList do
end
end
- context "with duplicated names", :chef_gte_13_only do
+ context "with duplicated names", chef: ">= 13" do
it "should fail in Chef 13" do
expect(list).to_not respond_to(:with_duplicate_names)
end