diff options
| author | danielsdeleo <dan@opscode.com> | 2013-04-18 12:53:20 -0700 |
|---|---|---|
| committer | danielsdeleo <dan@opscode.com> | 2013-04-18 12:53:20 -0700 |
| commit | 2cc7d616caccc2fd0cb0e0b851e05ba33b95af80 (patch) | |
| tree | 8841fbbffb77417e980bc062f4cae59be105b8f0 /spec/unit/lwrp_spec.rb | |
| parent | 20e2b37faf73a41b80b47d9f0e3172f5c97723d4 (diff) | |
| download | chef-2cc7d616caccc2fd0cb0e0b851e05ba33b95af80.tar.gz | |
[CHEF-3432] fix leak of LWRP resource classes
Diffstat (limited to 'spec/unit/lwrp_spec.rb')
| -rw-r--r-- | spec/unit/lwrp_spec.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 14501c51c7..3e807bc06c 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -34,7 +34,7 @@ describe "LWRP" do $stderr.stub!(:write) end - it "should log if attempting to load resource of same name", :focus do + it "should log if attempting to load resource of same name" do Dir[File.expand_path( "lwrp/resources/*", CHEF_SPEC_DATA)].each do |file| Chef::Resource::LWRPBase.build_from_file("lwrp", file, nil) end @@ -56,6 +56,22 @@ describe "LWRP" do end end + it "removes the old LRWP resource class from the list of resource subclasses [CHEF-3432]" do + # CHEF-3432 regression test: + # Chef::Resource keeps a list of all subclasses to assist class inflation + # for json parsing (see Chef::JSONCompat). When replacing LWRP resources, + # we need to ensure the old resource class is remove from that list. + Dir[File.expand_path( "lwrp/resources/*", CHEF_SPEC_DATA)].each do |file| + Chef::Resource::LWRPBase.build_from_file("lwrp", file, nil) + end + first_lwr_foo_class = Chef::Resource::LwrpFoo + Chef::Resource.resource_classes.should include(first_lwr_foo_class) + Dir[File.expand_path( "lwrp/resources/*", CHEF_SPEC_DATA)].each do |file| + Chef::Resource::LWRPBase.build_from_file("lwrp", file, nil) + end + Chef::Resource.resource_classes.should_not include(first_lwr_foo_class) + end + end describe "Lightweight Chef::Resource" do |
