From db59fd9392a97328df8d7ba7f1c2b1fc03058e76 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Tue, 16 Jun 2015 16:27:52 -0700 Subject: Sort identical "provides" alphabetically (for backcompat) - Warn when multiple providers try to provide the same thing --- spec/unit/recipe_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'spec/unit/recipe_spec.rb') diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb index 7579abf227..17ea498fe3 100644 --- a/spec/unit/recipe_spec.rb +++ b/spec/unit/recipe_spec.rb @@ -153,24 +153,24 @@ describe Chef::Recipe do Object.send(:remove_const, :TottenhamHotspur) end - it "selects one if it is the last declared" do - expect(Chef::Log).not_to receive(:warn) + it "selects the first one alphabetically" do + expect(Chef::Log).to receive(:warn).with("You declared a new resource TottenhamHotspur for resource football, but it comes alphabetically after Sounders and has the same filters ({:platform=>\"nbc_sports\"}), so it will not be used. Use override: true if you want to use it for football.") Sounders.provides :football, platform: "nbc_sports" TottenhamHotspur.provides :football, 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) + expect(res1).to be_a_kind_of(Sounders) end - it "selects the other one if it is given priority" do - expect(Chef::Log).not_to receive(:warn) + it "selects the first one alphabetically even if the declaration order is reversed" do + expect(Chef::Log).to receive(:warn).with("You are overriding football2 on {:platform=>\"nbc_sports\"} with Sounders: used to be TottenhamHotspur. Use override: true if this is what you intended.") - TottenhamHotspur.provides :football, platform: "nbc_sports" - Sounders.provides :football, platform: "nbc_sports" + TottenhamHotspur.provides :football2, platform: "nbc_sports" + Sounders.provides :football2, platform: "nbc_sports" - res1 = recipe.football "club world cup" + res1 = recipe.football2 "club world cup" expect(res1.name).to eql("club world cup") expect(res1).to be_a_kind_of(Sounders) end -- cgit v1.2.1