diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-03 12:58:19 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-03 15:12:48 -0800 |
commit | 3a87159beb91315401a3b88ea847ae6821e0ab88 (patch) | |
tree | 6a982e97f0817702b8ed12c62697ccc38a3974e0 /spec/unit/lwrp_spec.rb | |
parent | 235622a134cecf6696bcb451038618dc682108cc (diff) | |
download | chef-3a87159beb91315401a3b88ea847ae6821e0ab88.tar.gz |
fix LWRP constant lookups
* providers had the same bug as CHEF-4117 on resources
* removed the strict_const_defined method on Chef::Resource since
ruby 1.8.7 deprecation made that method entirely trivial
* added tests, verified the failure cases really work
* todo added since i think we're leaking state in-between tests
Diffstat (limited to 'spec/unit/lwrp_spec.rb')
-rw-r--r-- | spec/unit/lwrp_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 35963dec64..64a2176e76 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -36,6 +36,30 @@ describe "LWRP" do allow($stderr).to receive(:write) end + it "should not skip loading a resource when there's a top level symbol of the same name" do + Object.const_set('LwrpFoo', Class.new) + file = File.expand_path( "lwrp/resources/foo.rb", CHEF_SPEC_DATA) + expect(Chef::Log).not_to receive(:info).with(/Skipping/) + expect(Chef::Log).not_to receive(:debug).with(/anymore/) + Chef::Resource::LWRPBase.build_from_file("lwrp", file, nil) + Object.send(:remove_const, 'LwrpFoo') + Chef::Resource.send(:remove_const, 'LwrpFoo') + end + + it "should not skip loading a provider when there's a top level symbol of the same name" do + Object.const_set('LwrpBuckPasser', Class.new) + file = File.expand_path( "lwrp/providers/buck_passer.rb", CHEF_SPEC_DATA) + expect(Chef::Log).not_to receive(:info).with(/Skipping/) + expect(Chef::Log).not_to receive(:debug).with(/anymore/) + Chef::Provider::LWRPBase.build_from_file("lwrp", file, nil) + Object.send(:remove_const, 'LwrpBuckPasser') + Chef::Provider.send(:remove_const, 'LwrpBuckPasser') + end + + # @todo: we need a before block to manually remove_const all of the LWRPs that we + # load in these tests. we're threading state through these tests in LWRPs that + # have already been loaded in prior tests, which probably renders some of them bogus + 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) |