diff options
author | John Keiser <john@johnkeiser.com> | 2015-05-07 16:24:45 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-05-13 13:43:15 -0700 |
commit | 146f0809c1912988751688fff2ef6945c90a4513 (patch) | |
tree | 96e6ac327717318984930b84f69d8690a78b631c /spec/unit/lwrp_spec.rb | |
parent | 0700ce4cd87825c6a925036ad5143ceb79438d38 (diff) | |
download | chef-146f0809c1912988751688fff2ef6945c90a4513.tar.gz |
Deprecate Chef::Provider::LwrpClass the same way we did Resource
Diffstat (limited to 'spec/unit/lwrp_spec.rb')
-rw-r--r-- | spec/unit/lwrp_spec.rb | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 07b2c9d88c..36b470295f 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -320,38 +320,43 @@ describe "LWRP" do end before(:each) do - Dir[File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "lwrp", "resources", "*"))].each do |file| + Dir[File.expand_path(File.expand_path("../../data/lwrp/resources/*", __FILE__))].each do |file| Chef::Resource::LWRPBase.build_from_file("lwrp", file, @run_context) end - Dir[File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "lwrp", "providers", "*"))].each do |file| - Chef::Provider::LWRPBase.build_from_file("lwrp", file, @run_context) - end - - Dir[File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "lwrp_override", "providers", "*"))].each do |file| + Dir[File.expand_path(File.expand_path("../../data/lwrp/providers/*", __FILE__))].each do |file| Chef::Provider::LWRPBase.build_from_file("lwrp", file, @run_context) end end it "should properly handle a new_resource reference" do - resource = get_lwrp(:lwrp_foo).new("morpheus") + resource = get_lwrp(:lwrp_foo).new("morpheus", @run_context) resource.monkey("bob") resource.provider(:lwrp_monkey_name_printer) - resource.run_context = @run_context provider = Chef::Platform.provider_for_resource(resource, :twiddle_thumbs) provider.action_twiddle_thumbs end - it "should load the provider into a properly-named class" do - expect(Chef::Provider.const_get("LwrpBuckPasser")).to be_kind_of(Class) - end + context "resource class created" do + before do + @old_treat_deprecation_warnings_as_errors = Chef::Config[:treat_deprecation_warnings_as_errors] + Chef::Config[:treat_deprecation_warnings_as_errors] = false + end + after do + Chef::Config[:treat_deprecation_warnings_as_errors] = @old_treat_deprecation_warnings_as_errors + end - it "should create a method for each attribute" do - new_resource = double("new resource").as_null_object - expect(Chef::Provider::LwrpBuckPasser.new(nil, new_resource).methods.map{|m|m.to_sym}).to include(:action_pass_buck) - expect(Chef::Provider::LwrpThumbTwiddler.new(nil, new_resource).methods.map{|m|m.to_sym}).to include(:action_twiddle_thumbs) + it "should load the provider into a properly-named class" do + expect(Chef::Provider.const_get("LwrpBuckPasser")).to be_kind_of(Class) + expect(Chef::Provider::LwrpBuckPasser <= Chef::Provider::LWRPBase).to be_truthy + end + + it "should create a method for each action" do + expect(Chef::Provider::LwrpBuckPasser.instance_methods).to include(:action_pass_buck) + expect(Chef::Provider::LwrpThumbTwiddler.instance_methods).to include(:action_twiddle_thumbs) + end end it "should insert resources embedded in the provider into the middle of the resource collection" do |