diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-04-11 12:48:22 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-04-15 17:50:15 -0700 |
commit | e3a6565927e854cd5968bd3a6bd2248ec1245549 (patch) | |
tree | 590bfa3f9c3a4992096c0ccb679fcc7deda74243 /spec/unit/recipe_spec.rb | |
parent | a959404b15ba6bdc98063cfa0c70e6f9eec9ccee (diff) | |
download | chef-e3a6565927e854cd5968bd3a6bd2248ec1245549.tar.gz |
add resource_resolver and resource_priority_map
also wire them up through the Chef class.
Diffstat (limited to 'spec/unit/recipe_spec.rb')
-rw-r--r-- | spec/unit/recipe_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb index b370e12732..7442f4477e 100644 --- a/spec/unit/recipe_spec.rb +++ b/spec/unit/recipe_spec.rb @@ -20,6 +20,7 @@ # require 'spec_helper' +require 'chef/platform/resource_priority_map' describe Chef::Recipe do @@ -136,6 +137,44 @@ describe Chef::Recipe do res.kind_of?(YourMom) end + describe "when there is more than one resource that resolves on a node" do + before do + node.automatic[:platform] = "nbc_sports" + Sounders = Class.new(Chef::Resource) + Sounders.provides :football, platform: "nbc_sports" + TottenhamHotspur = Class.new(Chef::Resource) + TottenhamHotspur.provides :football, platform: "nbc_sports" + end + + after do + Object.send(:remove_const, :Sounders) + Object.send(:remove_const, :TottenhamHotspur) + end + + it "warns if resolution of the two resources is ambiguous" do + expect(Chef::Log).to receive(:warn).at_least(:once).with(/Ambiguous resource precedence/) + res1 = recipe.football "club world cup" + expect(res1.name).to eql("club world cup") + # the class of res1 is not defined. + end + + it "selects one if it is given priority" do + expect(Chef::Log).not_to receive(:warn) + Chef::Platform::ResourcePriorityMap.instance.send(:priority, :football, TottenhamHotspur, platform: "nbc_sports") + res1 = recipe.football "club world cup" + expect(res1.name).to eql("club world cup") + expect(res1).to be_a_kind_of(TottenhamHotspur) + end + + it "selects the other one if it is given priority" do + expect(Chef::Log).not_to receive(:warn) + Chef::Platform::ResourcePriorityMap.instance.send(:priority, :football, Sounders, platform: "nbc_sports") + res1 = recipe.football "club world cup" + expect(res1.name).to eql("club world cup") + expect(res1).to be_a_kind_of(Sounders) + end + end + end end |