summaryrefslogtreecommitdiff
path: root/spec/unit/recipe_spec.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2014-02-19 09:43:54 -0800
committerdanielsdeleo <dan@opscode.com>2014-02-19 09:43:54 -0800
commitfd8db8959d3d683b2acb0c773abdc9ccf2d84ef7 (patch)
tree587b21e58f24c4ef3b9ddf39b64572d5c55915d9 /spec/unit/recipe_spec.rb
parent42591e642c4d297a20a9906d03978f5599445d45 (diff)
downloadchef-fd8db8959d3d683b2acb0c773abdc9ccf2d84ef7.tar.gz
Describe resource cloning behaviors in recipe specs.
Includes two regression tests for CHEF-5052, marked pending until the fix for that issue is merged.
Diffstat (limited to 'spec/unit/recipe_spec.rb')
-rw-r--r--spec/unit/recipe_spec.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 48c782deae..6df53acae8 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -225,6 +225,55 @@ describe Chef::Recipe do
end
+ describe "resource cloning" do
+
+ let(:second_recipe) do
+ Chef::Recipe.new("second_cb", "second_recipe", run_context)
+ end
+
+ let(:original_resource) do
+ recipe.zen_master("klopp") do
+ something "bvb09"
+ action :score
+ end
+ end
+
+ let(:duplicated_resource) do
+ original_resource
+ second_recipe.zen_master("klopp") do
+ # attrs should be cloned
+ end
+ end
+
+ it "copies attributes from the first resource" do
+ duplicated_resource.something.should == "bvb09"
+ end
+
+ it "does not copy the action from the first resource" do
+ original_resource.action.should == [:score]
+ duplicated_resource.action.should == :nothing
+ end
+
+ it "does not copy the source location of the first resource" do
+ # sanity check source location:
+ original_resource.source_line.should include(__FILE__)
+ duplicated_resource.source_line.should include(__FILE__)
+ # actual test:
+ original_resource.source_line.should_not == duplicated_resource.source_line
+ end
+
+ it "sets the cookbook name on the cloned resource to that resource's cookbook" do
+ pending "CHEF-5052"
+ duplicated_resource.cookbook_name.should == "second_cb"
+ end
+
+ it "sets the recipe name on the cloned resource to that resoure's recipe" do
+ pending "CHEF-5052"
+ duplicated_resource.recipe_name.should == "second_recipe"
+ end
+
+ end
+
describe "resource definitions" do
it "should execute defined resources" do
crow_define = Chef::ResourceDefinition.new