diff options
author | John Keiser <john@johnkeiser.com> | 2015-06-16 13:49:26 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-06-16 16:57:07 -0700 |
commit | 6fbe77bf0c3fa2f4683487fac87f79b1eb6c293e (patch) | |
tree | 670157649ee8529602ff7845c43d785647fca2d7 /spec/unit/resource_spec.rb | |
parent | 7f81d08720d59df974ec4d5416fd24fafc2ad824 (diff) | |
download | chef-6fbe77bf0c3fa2f4683487fac87f79b1eb6c293e.tar.gz |
Only automatically set resources that do class X < Chef::Resource,jk/3524
not X = Class.new(Chef::Resource)
Diffstat (limited to 'spec/unit/resource_spec.rb')
-rw-r--r-- | spec/unit/resource_spec.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 8ba45d9350..87f7f8d929 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -344,6 +344,7 @@ describe Chef::Resource do expect(r.resource_name).to be_nil expect(r.declared_type).to eq :d end + it "and there are no provides lines, @resource_name is used" do c = Class.new(Chef::Resource) do def initialize(*args, &block) @@ -358,6 +359,20 @@ describe Chef::Resource do expect(r.resource_name).to eq :blah expect(r.declared_type).to eq :d end + + it "and the resource class gets a late-bound name, resource_name is nil" do + c = Class.new(Chef::Resource) do + def self.name + "ResourceSpecNameTest" + end + end + + r = c.new('hi') + r.declared_type = :d + expect(c.resource_name).to be_nil + expect(r.resource_name).to be_nil + expect(r.declared_type).to eq :d + end end it "resource_name without provides is honored" do @@ -416,7 +431,7 @@ describe Chef::Resource do expect(json).to match(/instance_vars/) end - include_examples "to_json equalivent to Chef::JSONCompat.to_json" do + include_examples "to_json equivalent to Chef::JSONCompat.to_json" do let(:jsonable) { @resource } end end |