summaryrefslogtreecommitdiff
path: root/spec/unit/lwrp_spec.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-04-23 14:27:02 -0700
committerdanielsdeleo <dan@opscode.com>2013-04-23 14:27:02 -0700
commit5f3942e73de403006b8448b992a7f6c8aab2d15a (patch)
treedea752e38552dc0880af88881762322e380ad4f0 /spec/unit/lwrp_spec.rb
parenta81d760fffcc798ffbfab733ffaa6ec51990e463 (diff)
downloadchef-5f3942e73de403006b8448b992a7f6c8aab2d15a.tar.gz
[CHEF-4117] fix resource attempting to remove constants it doesn't have
Module.const_defined?() needs to be given an optional second argument to disable constant lookups on ancestor classes. Otherwise LWRP creation may attempt to remove a constant that does not exist.
Diffstat (limited to 'spec/unit/lwrp_spec.rb')
-rw-r--r--spec/unit/lwrp_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index 3e807bc06c..19d3504f3c 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -18,6 +18,8 @@
require 'spec_helper'
+module LwrpConstScopingConflict
+end
describe "LWRP" do
before do
@@ -72,6 +74,12 @@ describe "LWRP" do
Chef::Resource.resource_classes.should_not include(first_lwr_foo_class)
end
+ it "does not attempt to remove classes from higher up namespaces [CHEF-4117]" do
+ conflicting_lwrp_file = File.expand_path( "lwrp_const_scoping/resources/conflict.rb", CHEF_SPEC_DATA)
+ # The test is that this should not raise an error:
+ Chef::Resource::LWRPBase.build_from_file("lwrp_const_scoping", conflicting_lwrp_file, nil)
+ end
+
end
describe "Lightweight Chef::Resource" do