summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-05-06 16:17:53 -0700
committerJohn Keiser <john@johnkeiser.com>2015-06-02 09:53:39 -0700
commit9fae7c1c1cf6f75834e309692a6b45dcbab11de1 (patch)
treeaf3af923d962956f687cd69447dffc5d607742fd
parentea5c98fd538dd07d3dd98ab2cf01f6e99c0fe31c (diff)
downloadchef-9fae7c1c1cf6f75834e309692a6b45dcbab11de1.tar.gz
Fix resource unit test
-rw-r--r--lib/chef/provider.rb3
-rw-r--r--lib/chef/resource.rb6
-rw-r--r--spec/unit/resource_spec.rb12
3 files changed, 11 insertions, 10 deletions
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index 984ad0974a..8027e39a3f 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -176,8 +176,7 @@ class Chef
end
def self.provides(short_name, opts={}, &block)
- priority_map = Chef::Platform::ProviderPriorityMap.instance
- priority_map.priority(short_name, self, opts, &block)
+ Chef.set_provider_priority_array(short_name, self, opts, &block)
end
def self.provides?(node, resource)
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index caced28721..0547258f42 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -1104,8 +1104,7 @@ class Chef
end
def self.provides(name, opts={}, &block)
- priority_map = Chef::Platform::ResourcePriorityMap.instance
- result = priority_map.priority(name, self, opts, &block)
+ result = Chef.set_resource_priority_array(name, self, opts, &block)
Chef::DSL::Resources.add_resource_dsl(name)
result
end
@@ -1321,3 +1320,6 @@ class Chef
end
end
end
+
+# Requiring things at the bottom breaks cycles
+require 'chef/chef_class'
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index fefe78fbda..95de09f5ce 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -809,22 +809,22 @@ describe Chef::Resource do
end
it 'adds mappings for a single platform' do
- expect(Chef::Resource::Klz.node_map).to receive(:set).with(
- :dinobot, true, { platform: ['autobots'] }
+ expect(Chef).to receive(:set_resource_priority_array).with(
+ :dinobot, Chef::Resource::Klz, { platform: ['autobots'] }
)
klz.provides :dinobot, platform: ['autobots']
end
it 'adds mappings for multiple platforms' do
- expect(Chef::Resource::Klz.node_map).to receive(:set).with(
- :energy, true, { platform: ['autobots', 'decepticons']}
+ expect(Chef).to receive(:set_resource_priority_array).with(
+ :energy, Chef::Resource::Klz, { platform: ['autobots', 'decepticons']}
)
klz.provides :energy, platform: ['autobots', 'decepticons']
end
it 'adds mappings for all platforms' do
- expect(Chef::Resource::Klz.node_map).to receive(:set).with(
- :tape_deck, true, {}
+ expect(Chef).to receive(:set_resource_priority_array).with(
+ :tape_deck, Chef::Resource::Klz, {}
)
klz.provides :tape_deck
end