diff options
author | Mal Graty <mal.graty@googlemail.com> | 2013-03-02 00:16:53 +0000 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2013-05-24 07:12:45 -0700 |
commit | 4cc156b3b308c879502f86a3de6d44737e1b1920 (patch) | |
tree | a0005607266d0a8a699899200743835cf72ed72f /spec | |
parent | 655444799b7acb90e40161684211352025d008f1 (diff) | |
download | chef-4cc156b3b308c879502f86a3de6d44737e1b1920.tar.gz |
Tests CHEF-3307
Test cookbook loading, shadowing and metadata deprecation warnings assocaited
with the CHEF-3307 changes (use of metadata name as cookbook name in preference
to file system pathname).
Includes new nginx cookbook (with alternate pathname) and a shadowbook with
another pathname.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/data/cookbooks/not-nginx/attributes/default.rb | 1 | ||||
-rw-r--r-- | spec/data/cookbooks/not-nginx/metadata.rb | 1 | ||||
-rw-r--r-- | spec/data/kitchen/no-really-not-nginx/attributes/default.rb | 1 | ||||
-rw-r--r-- | spec/data/kitchen/no-really-not-nginx/metadata.rb | 1 | ||||
-rw-r--r-- | spec/unit/cookbook_loader_spec.rb | 23 |
5 files changed, 26 insertions, 1 deletions
diff --git a/spec/data/cookbooks/not-nginx/attributes/default.rb b/spec/data/cookbooks/not-nginx/attributes/default.rb new file mode 100644 index 0000000000..be06213478 --- /dev/null +++ b/spec/data/cookbooks/not-nginx/attributes/default.rb @@ -0,0 +1 @@ +default[:cheese] = 'mr whiskers' diff --git a/spec/data/cookbooks/not-nginx/metadata.rb b/spec/data/cookbooks/not-nginx/metadata.rb new file mode 100644 index 0000000000..85e7200e2b --- /dev/null +++ b/spec/data/cookbooks/not-nginx/metadata.rb @@ -0,0 +1 @@ +name "nginx" diff --git a/spec/data/kitchen/no-really-not-nginx/attributes/default.rb b/spec/data/kitchen/no-really-not-nginx/attributes/default.rb new file mode 100644 index 0000000000..7987157ec2 --- /dev/null +++ b/spec/data/kitchen/no-really-not-nginx/attributes/default.rb @@ -0,0 +1 @@ +default[:wine] = 'captain socks' diff --git a/spec/data/kitchen/no-really-not-nginx/metadata.rb b/spec/data/kitchen/no-really-not-nginx/metadata.rb new file mode 100644 index 0000000000..85e7200e2b --- /dev/null +++ b/spec/data/kitchen/no-really-not-nginx/metadata.rb @@ -0,0 +1 @@ +name "nginx" diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb index 1d694b5ef6..5bd7b62183 100644 --- a/spec/unit/cookbook_loader_spec.rb +++ b/spec/unit/cookbook_loader_spec.rb @@ -67,7 +67,8 @@ describe Chef::CookbookLoader do seen[1].should == "apache2" seen[2].should == "borken" seen[3].should == "java" - seen[4].should == "openldap" + seen[4].should == "nginx" + seen[5].should == "openldap" end end @@ -154,6 +155,26 @@ describe Chef::CookbookLoader do end @cookbook_loader.load_cookbooks end + + it "should index cookbooks by name, not pathname" do + @cookbook_loader.should_not have_key(:'not-nginx') + @cookbook_loader.should_not have_key(:'no-really-not-nginx') + @cookbook_loader.should have_key(:nginx) + end + + it "should shadow cookbooks by name, not pathname" do + @cookbook_loader[:nginx].attribute_filenames.detect { |f| + f =~ /cookbooks\/not-nginx\/attributes\/default.rb/ + }.should_not eql(nil) + @cookbook_loader[:nginx].attribute_filenames.detect { |f| + f =~ /kitchen\/no-really-not-nginx\/attributes\/default.rb/ + }.should eql(nil) + end + + it "should emit deprecation warning if name is not in metadata" do + Chef::Log.should_receive(:warn).exactly(6).with("Inferred cookbook names are deprecated, please set a name in metadata") + @cookbook_loader.load_cookbooks + end end # load_cookbooks end # loading all cookbooks |