diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-12 14:10:29 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-12 14:10:29 -0800 |
commit | 5959add42e911e14918c41d0212f6ba8e0425d11 (patch) | |
tree | ff8f50461fe5bac36366013d715ea6b2b04868e0 | |
parent | 23e71b551db1908603345ff196e0dddeff01ba4f (diff) | |
download | chef-5959add42e911e14918c41d0212f6ba8e0425d11.tar.gz |
fix specs
-rw-r--r-- | lib/chef/cookbook_loader.rb | 2 | ||||
-rw-r--r-- | spec/unit/cookbook_loader_spec.rb | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/cookbook_loader.rb b/lib/chef/cookbook_loader.rb index 4668521817..c0fd515bf2 100644 --- a/lib/chef/cookbook_loader.rb +++ b/lib/chef/cookbook_loader.rb @@ -85,6 +85,8 @@ class Chef def load_cookbook(cookbook_name) preload_cookbooks + return @cookbooks_by_name[cookbook_name] if @cookbooks_by_name.has_key?(cookbook_name) + return nil unless @loaders_by_name.key?(cookbook_name.to_s) cookbook_loaders_for(cookbook_name).each do |loader| diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb index 3f4a7486ce..db10a4eb4f 100644 --- a/spec/unit/cookbook_loader_spec.rb +++ b/spec/unit/cookbook_loader_spec.rb @@ -45,14 +45,23 @@ describe Chef::CookbookLoader do once. and_call_original end + expect(Chef::Log).to receive(:deprecation).with(/The cookbook\(s\): openldap exist in multiple places in your cookbook_path./) cookbook_loader.load_cookbooks end context "after loading all cookbooks" do before(:each) do + expect(Chef::Log).to receive(:deprecation).with(/The cookbook\(s\): openldap exist in multiple places in your cookbook_path./) cookbook_loader.load_cookbooks end + it "should be possible to reload all the cookbooks without triggering deprecation warnings on all of them" do + start_merged_cookbooks = cookbook_loader.merged_cookbooks + expect(Chef::Log).to receive(:deprecation).with(/The cookbook\(s\): openldap exist in multiple places in your cookbook_path./) + cookbook_loader.load_cookbooks + expect(cookbook_loader.merged_cookbooks).to eql(start_merged_cookbooks) + end + describe "[]" do it "should return cookbook objects with []" do expect(cookbook_loader[:openldap]).to be_a_kind_of(Chef::CookbookVersion) @@ -98,7 +107,6 @@ describe Chef::CookbookLoader do describe "referencing cookbook files" do it "should find all the cookbooks in the cookbook path" do - cookbook_loader.load_cookbooks expect(cookbook_loader).to have_key(:openldap) expect(cookbook_loader).to have_key(:apache2) end @@ -260,6 +268,7 @@ describe Chef::CookbookLoader do describe "loading all cookbooks after loading only one cookbook" do before(:each) do + expect(Chef::Log).to receive(:deprecation).with(/The cookbook\(s\): openldap exist in multiple places in your cookbook_path./) cookbook_loader.load_cookbooks end |