summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-05-28 11:32:10 -0700
committerJohn Keiser <john@johnkeiser.com>2015-06-01 08:02:05 -0700
commit46e3f2258b1b04ca6030b5ef1575adadaa920e08 (patch)
treef59066b287aee399b923de9346be4a42f4e20924 /spec/unit
parent5998cc7315507e649bb76f139c07715f6e590707 (diff)
downloadchef-46e3f2258b1b04ca6030b5ef1575adadaa920e08.tar.gz
Add use_automatic_resource_name
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/recipe_spec.rb4
-rw-r--r--spec/unit/resource_spec.rb14
2 files changed, 18 insertions, 0 deletions
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 9c4fb49497..59d05298c3 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -121,6 +121,7 @@ describe Chef::Recipe do
it "locate resource for particular platform" do
ShaunTheSheep = Class.new(Chef::Resource)
+ ShaunTheSheep.use_automatic_resource_name
ShaunTheSheep.provides :laughter, :on_platforms => ["television"]
node.automatic[:platform] = "television"
node.automatic[:platform_version] = "123"
@@ -131,6 +132,7 @@ describe Chef::Recipe do
it "locate a resource for all platforms" do
YourMom = Class.new(Chef::Resource)
+ YourMom.use_automatic_resource_name
YourMom.provides :love_and_caring
res = recipe.love_and_caring "mommy"
expect(res.name).to eql("mommy")
@@ -141,8 +143,10 @@ describe Chef::Recipe do
before do
node.automatic[:platform] = "nbc_sports"
Sounders = Class.new(Chef::Resource)
+ Sounders.use_automatic_resource_name
Sounders.provides :football, platform: "nbc_sports"
TottenhamHotspur = Class.new(Chef::Resource)
+ TottenhamHotspur.use_automatic_resource_name
TottenhamHotspur.provides :football, platform: "nbc_sports"
end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 2e0a88f555..bc5567b73a 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -399,6 +399,20 @@ describe Chef::Resource do
expect(r.resource_name).to eq :blah
expect(r.declared_type).to eq :d
end
+ it "use_automatic_resource_name yields a resource name from the class name" do
+ class SelfResourceNameTestBlahDBlah4 < Chef::Resource
+ use_automatic_resource_name
+ end
+
+ c = SelfResourceNameTestBlahDBlah4
+
+ r = c.new('hi')
+ r.declared_type = :d
+ expect(c.resource_name).to eq :self_resource_name_test_blah_d_blah4
+ expect(r.resource_name).to eq :self_resource_name_test_blah_d_blah4
+ expect(r.declared_type).to eq :d
+
+ end
end
describe "is" do