diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2017-04-04 10:45:41 -0700 |
---|---|---|
committer | Noah Kantrowitz <noah@coderanger.net> | 2017-04-04 10:45:41 -0700 |
commit | 11a07953165b631eb3612a00560a24fa14d14606 (patch) | |
tree | b4011db7d33e99186e9e9c124d62040db1e6bb3f | |
parent | 848404e77096c19ba8689927330c61e12cbd10fb (diff) | |
parent | 93c72873224c6a79ae13b5d2fa70cb9bfc645c5c (diff) | |
download | chef-11a07953165b631eb3612a00560a24fa14d14606.tar.gz |
Merge branch 'master' into freeze-property-default
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
-rw-r--r-- | Gemfile.lock | 2 | ||||
-rw-r--r-- | RELEASE_NOTES.md | 15 | ||||
-rw-r--r-- | acceptance/data-collector/test/integration/default/serverspec/default_spec.rb | 4 | ||||
-rw-r--r-- | kitchen-tests/Berksfile | 9 | ||||
-rw-r--r-- | kitchen-tests/Berksfile.lock | 60 | ||||
-rw-r--r-- | lib/chef/chef_fs/chef_fs_data_store.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider.rb | 27 | ||||
-rw-r--r-- | lib/chef/provider/launchd.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/lwrp_base.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/systemd_unit.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/user/linux.rb | 1 | ||||
-rw-r--r-- | lib/chef/resource.rb | 22 | ||||
-rw-r--r-- | lib/chef/resource/launchd.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource/lwrp_base.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/systemd_unit.rb | 5 | ||||
-rw-r--r-- | spec/integration/knife/serve_spec.rb | 80 | ||||
-rw-r--r-- | spec/unit/lwrp_spec.rb | 107 |
17 files changed, 114 insertions, 234 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index 8d9447bee3..11e8191d15 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,7 +37,7 @@ GIT GIT remote: https://github.com/chef/ohai.git - revision: 58296dc0035e4f94a7b7cdc1db01887a3c3c1e30 + revision: 21cc711810e860d9db378f39da88406eec48d878 specs: ohai (13.0.0) chef-config (>= 12.5.0.alpha.1, < 14) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 27fa342e52..3a459b9a18 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -210,6 +210,21 @@ This change allows chef to support new classes of files, such as Ohai plugins or Inspec tests, without having to make changes to the cookbook format to support them. +### DSL-based custom resources and providers no longer get module constants + +Up until now, creating a `mycook/resources/thing.rb` would create a `Chef::Resources::MycookThing` name to access the resource class object. +This const is no longer created for resources and providers. You can access resource classes through the resolver API like: + +```ruby +Chef::Resource.resource_for_node(:mycook_thing, node) +``` + +Accessing a provider class is a bit more complex, as you need a resource against which to run a resolution like so: + +```ruby +Chef::ProviderResolver.new(node, find_resource!("mycook_thing[name]"), :nothing).resolve +``` + ### Default values for resource properties are frozen A resource declaring something like: diff --git a/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb b/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb index 59c1f8d21b..040fbcbcca 100644 --- a/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb +++ b/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb @@ -108,6 +108,8 @@ shared_examples_for "run_converge.success payload check" do node node_name organization_name + policy_name + policy_group resources run_id run_list @@ -145,6 +147,8 @@ shared_examples_for "run_converge.failure payload check" do node node_name organization_name + policy_name + policy_group resources run_id run_list diff --git a/kitchen-tests/Berksfile b/kitchen-tests/Berksfile index 09e4cea33a..9a2df463fc 100644 --- a/kitchen-tests/Berksfile +++ b/kitchen-tests/Berksfile @@ -7,7 +7,8 @@ cookbook "php", "~> 1.5.0" cookbook "resolver", github: "chef-cookbooks/resolver" -cookbook "awesome_customers_ubuntu_wrapper", path: "cookbooks/awesome_customers_ubuntu_wrapper" -cookbook "awesome_customers_ubuntu", github: "lamont-granquist/awesome_customers_ubuntu", branch: "lcg/bump-mysql-version" -cookbook "awesome_customers_rhel_wrapper", path: "cookbooks/awesome_customers_rhel_wrapper" -cookbook "awesome_customers_rhel", github: "lamont-granquist/awesome_customers_rhel", branch: "lcg/bump-mysql-version" +# Disabled pending updating these test cases for Chef 13. +# cookbook "awesome_customers_ubuntu_wrapper", path: "cookbooks/awesome_customers_ubuntu_wrapper" +# cookbook "awesome_customers_ubuntu", github: "lamont-granquist/awesome_customers_ubuntu", branch: "lcg/bump-mysql-version" +# cookbook "awesome_customers_rhel_wrapper", path: "cookbooks/awesome_customers_rhel_wrapper" +# cookbook "awesome_customers_rhel", github: "lamont-granquist/awesome_customers_rhel", branch: "lcg/bump-mysql-version" diff --git a/kitchen-tests/Berksfile.lock b/kitchen-tests/Berksfile.lock index 5231491687..c9d533da60 100644 --- a/kitchen-tests/Berksfile.lock +++ b/kitchen-tests/Berksfile.lock @@ -1,16 +1,4 @@ DEPENDENCIES - awesome_customers_rhel - git: https://github.com/lamont-granquist/awesome_customers_rhel.git - revision: ed730957b1b75c8701c708e2deb0740ca8325322 - branch: lcg/bump-mysql-version - awesome_customers_rhel_wrapper - path: cookbooks/awesome_customers_rhel_wrapper - awesome_customers_ubuntu - git: https://github.com/lamont-granquist/awesome_customers_ubuntu.git - revision: 9d40958413d0ed1ef1e68c74d41895158c724964 - branch: lcg/bump-mysql-version - awesome_customers_ubuntu_wrapper - path: cookbooks/awesome_customers_ubuntu_wrapper base path: cookbooks/base php (~> 1.5.0) @@ -19,26 +7,7 @@ DEPENDENCIES revision: 4ab8cb0dfee3696fb8a1e4398e95bff9f33fd6ab GRAPH - apt (4.0.2) - compat_resource (>= 12.10) - awesome_customers_rhel (0.1.0) - database (~> 6.0) - firewall (~> 2.5) - httpd (~> 0.4) - mysql (~> 8.0) - mysql2_chef_gem (~> 1.1) - selinux (~> 0.9) - awesome_customers_rhel_wrapper (0.1.0) - awesome_customers_rhel (>= 0.0.0) - awesome_customers_ubuntu (0.1.0) - apt (~> 4.0) - database (~> 6.0) - firewall (~> 2.5) - httpd (~> 0.4) - mysql (~> 8.0) - mysql2_chef_gem (~> 1.1) - awesome_customers_ubuntu_wrapper (0.1.0) - awesome_customers_ubuntu (>= 0.0.0) + apt (6.0.1) base (0.1.0) apt (>= 0.0.0) build-essential (>= 0.0.0) @@ -61,17 +30,10 @@ GRAPH cron (>= 1.7.0) logrotate (>= 1.9.0) windows (>= 1.42.0) - chef-sugar (3.4.0) chef_hostname (0.5.0) compat_resource (12.16.3) cron (4.1.0) compat_resource (>= 0.0.0) - database (6.1.1) - postgresql (>= 1.0.0) - firewall (2.5.4) - chef-sugar (>= 0.0.0) - httpd (0.4.5) - compat_resource (>= 12.16.3) iis (5.1.0) windows (>= 2.0) inifile_chef_gem (0.1.0) @@ -79,26 +41,16 @@ GRAPH iptables (4.0.1) logrotate (2.1.0) compat_resource (>= 0.0.0) - mariadb (1.3.0) - apt (>= 0.0.0) - yum (>= 0.0.0) - yum-epel (>= 0.0.0) - yum-scl (>= 0.0.0) mingw (2.0.0) seven_zip (>= 0.0.0) multipackage (4.0.0) compat_resource (>= 0.0.0) mysql (8.3.0) - mysql2_chef_gem (1.1.0) - build-essential (>= 0.0.0) - mariadb (>= 0.0.0) - mysql (>= 6.0) nscd (5.0.0) ntp (3.3.1) ohai (5.0.2) openssh (2.1.1) iptables (>= 1.0) - openssl (7.0.1) php (1.5.0) build-essential (>= 0.0.0) iis (>= 0.0.0) @@ -106,12 +58,8 @@ GRAPH windows (>= 0.0.0) xml (>= 0.0.0) yum-epel (>= 0.0.0) - postgresql (6.1.1) - build-essential (>= 2.0.0) - compat_resource (>= 12.16.3) - openssl (>= 4.0) resolver (2.0.1) - selinux (0.9.0) + selinux (1.0.3) seven_zip (2.0.2) windows (>= 1.2.2) sudo (3.3.1) @@ -122,9 +70,5 @@ GRAPH ohai (>= 4.0.0) xml (3.1.1) build-essential (>= 0.0.0) - yum (5.0.0) yum-epel (2.1.1) compat_resource (>= 12.16.3) - yum-scl (0.2.0) - inifile_chef_gem (>= 0.0.0) - yum (>= 0.0.0) diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb index 46fe5c4dd3..0c8f12f1be 100644 --- a/lib/chef/chef_fs/chef_fs_data_store.rb +++ b/lib/chef/chef_fs/chef_fs_data_store.rb @@ -768,7 +768,7 @@ class Chef end elsif path.length == 2 && path[0] != "cookbooks" - path[1] = path[1][0..-6] + path[1] = path[1].gsub(/\.(rb|json)/, "") end path diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb index 8334eab0a6..ce2f431fec 100644 --- a/lib/chef/provider.rb +++ b/lib/chef/provider.rb @@ -432,33 +432,6 @@ class Chef end end - module DeprecatedLWRPClass - def const_missing(class_name) - if Chef::Provider.deprecated_constants[class_name.to_sym] - Chef.deprecated(:custom_resource, "Using an LWRP provider by its name (#{class_name}) directly is no longer supported in Chef 12 and will be removed. Use Chef::ProviderResolver.new(node, resource, action) instead.") - Chef::Provider.deprecated_constants[class_name.to_sym] - else - raise NameError, "uninitialized constant Chef::Provider::#{class_name}" - end - end - - # @api private - def register_deprecated_lwrp_class(provider_class, class_name) - # Register Chef::Provider::MyProvider with deprecation warnings if you - # try to access it - if Chef::Provider.const_defined?(class_name, false) - Chef::Log.warn "Chef::Provider::#{class_name} already exists! Cannot create deprecation class for #{provider_class}" - else - Chef::Provider.deprecated_constants[class_name.to_sym] = provider_class - end - end - - def deprecated_constants - raise "Deprecated constants should be called only on Chef::Provider" unless self == Chef::Provider - @deprecated_constants ||= {} - end - end - extend DeprecatedLWRPClass end end diff --git a/lib/chef/provider/launchd.rb b/lib/chef/provider/launchd.rb index a58954c707..9c368c2b48 100644 --- a/lib/chef/provider/launchd.rb +++ b/lib/chef/provider/launchd.rb @@ -85,6 +85,10 @@ class Chef manage_service(:disable) end + def action_restart + manage_service(:restart) + end + def manage_plist(action) if source res = cookbook_file_resource diff --git a/lib/chef/provider/lwrp_base.rb b/lib/chef/provider/lwrp_base.rb index cbf25f1e4f..1340b55ae4 100644 --- a/lib/chef/provider/lwrp_base.rb +++ b/lib/chef/provider/lwrp_base.rb @@ -75,8 +75,6 @@ class Chef LWRPBase.loaded_lwrps[filename] = true - Chef::Provider.register_deprecated_lwrp_class(provider_class, convert_to_class_name(resource_name)) - provider_class end diff --git a/lib/chef/provider/systemd_unit.rb b/lib/chef/provider/systemd_unit.rb index 5175dc6be9..143efe7b91 100644 --- a/lib/chef/provider/systemd_unit.rb +++ b/lib/chef/provider/systemd_unit.rb @@ -194,7 +194,7 @@ class Chef f.group "root" f.mode "0644" f.content new_resource.to_ini - f.verify :systemd_unit + f.verify :systemd_unit if new_resource.verify end.run_action(action) end diff --git a/lib/chef/provider/user/linux.rb b/lib/chef/provider/user/linux.rb index cf75bdc38b..715330e196 100644 --- a/lib/chef/provider/user/linux.rb +++ b/lib/chef/provider/user/linux.rb @@ -58,6 +58,7 @@ class Chef def usermod_options opts = [] + opts += [ "-u", new_resource.uid ] if non_unique? if updating_home? if new_resource.manage_home opts << "-m" diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index bd966f9c79..ca6603c06a 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -1488,27 +1488,6 @@ class Chef self.class.resource_for_node(name, node).new("name", run_context).provider_for_action(action).class end - module DeprecatedLWRPClass - - # @api private - def register_deprecated_lwrp_class(resource_class, class_name) - if Chef::Resource.const_defined?(class_name, false) - Chef::Log.warn "#{class_name} already exists! Deprecation class overwrites #{resource_class}" - Chef::Resource.send(:remove_const, class_name) - end - - if !Chef::Config[:treat_deprecation_warnings_as_errors] - Chef::Resource.const_set(class_name, resource_class) - Chef::Resource.deprecated_constants[class_name.to_sym] = resource_class - end - end - - def deprecated_constants - raise "Deprecated constants should be called only on Chef::Resource" unless self == Chef::Resource - @deprecated_constants ||= {} - end - end - def self.remove_canonical_dsl if @resource_name remaining = Chef.resource_handler_map.delete_canonical(@resource_name, self) @@ -1517,7 +1496,6 @@ class Chef end end end - extend DeprecatedLWRPClass end end diff --git a/lib/chef/resource/launchd.rb b/lib/chef/resource/launchd.rb index d158b1e165..3fba76e220 100644 --- a/lib/chef/resource/launchd.rb +++ b/lib/chef/resource/launchd.rb @@ -27,7 +27,7 @@ class Chef identity_attr :label default_action :create - allowed_actions :create, :create_if_missing, :delete, :enable, :disable + allowed_actions :create, :create_if_missing, :delete, :enable, :disable, :restart property :label, String, default: lazy { name }, identity: true property :backup, [Integer, FalseClass] @@ -114,7 +114,7 @@ class Chef property :ld_group, String property :limit_load_from_hosts, Array property :limit_load_to_hosts, Array - property :limit_load_to_session_type, Array + property :limit_load_to_session_type, [ Array, String ] property :low_priority_io, [ TrueClass, FalseClass ] property :mach_services, Hash property :nice, Integer diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb index 7dfe147341..b12ac98673 100644 --- a/lib/chef/resource/lwrp_base.rb +++ b/lib/chef/resource/lwrp_base.rb @@ -69,8 +69,6 @@ class Chef LWRPBase.loaded_lwrps[filename] = true - # Create the deprecated Chef::Resource::LwrpFoo class - Chef::Resource.register_deprecated_lwrp_class(resource_class, convert_to_class_name(resource_name)) resource_class end diff --git a/lib/chef/resource/systemd_unit.rb b/lib/chef/resource/systemd_unit.rb index 688f2e9dcd..1a19a7d682 100644 --- a/lib/chef/resource/systemd_unit.rb +++ b/lib/chef/resource/systemd_unit.rb @@ -33,14 +33,19 @@ class Chef :try_restart, :reload_or_restart, :reload_or_try_restart + # Internal provider-managed properties property :enabled, [TrueClass, FalseClass] property :active, [TrueClass, FalseClass] property :masked, [TrueClass, FalseClass] property :static, [TrueClass, FalseClass] + + # User-provided properties property :user, String, desired_state: false property :content, [String, Hash] property :triggers_reload, [TrueClass, FalseClass], default: true, desired_state: false + property :verify, [TrueClass, FalseClass], + default: true, desired_state: false def to_ini case content diff --git a/spec/integration/knife/serve_spec.rb b/spec/integration/knife/serve_spec.rb index 72f0bb59ed..b0cdd8c070 100644 --- a/spec/integration/knife/serve_spec.rb +++ b/spec/integration/knife/serve_spec.rb @@ -24,33 +24,69 @@ describe "knife serve", :workstation do include KnifeSupport include AppServerSupport + def with_knife_serve + exception = nil + t = Thread.new do + begin + knife("serve --chef-zero-port=8890") + rescue + exception = $! + end + end + begin + Chef::Config.log_level = :debug + Chef::Config.chef_server_url = "http://localhost:8890" + Chef::Config.node_name = nil + Chef::Config.client_key = nil + api = Chef::ServerAPI.new + yield api + rescue + if exception + raise exception + else + raise + end + ensure + t.kill + sleep 0.5 + end + end + when_the_repository "also has one of each thing" do - before { file "nodes/x.json", { "foo" => "bar" } } + before do + file "nodes/a_node_in_json.json", { "foo" => "bar" } + file "nodes/a_node_in_ruby.rb", "name 'a_node_in_ruby'" + file "roles/a_role_in_json.json", { "foo" => "bar" } + file "roles/a_role_in_ruby.rb", "name 'a_role_in_ruby'" + end - it "knife serve serves up /nodes/x" do - exception = nil - t = Thread.new do - begin - knife("serve --chef-zero-port=8890") - rescue - exception = $! + %w{a_node_in_json a_node_in_ruby}.each do |file_type| + context file_type do + it "knife serve serves up /nodes" do + with_knife_serve do |api| + expect(api.get("nodes")).to have_key(file_type) + end + end + it "knife serve serves up /nodes/#{file_type}" do + with_knife_serve do |api| + expect(api.get("nodes/#{file_type}")["name"]).to eq(file_type) + end end end - begin - Chef::Config.log_level = :debug - Chef::Config.chef_server_url = "http://localhost:8890" - Chef::Config.node_name = nil - Chef::Config.client_key = nil - api = Chef::ServerAPI.new - expect(api.get("nodes/x")["name"]).to eq("x") - rescue - if exception - raise exception - else - raise + end + + %w{a_role_in_json a_role_in_ruby}.each do |file_type| + context file_type do + it "knife serve serves up /roles" do + with_knife_serve do |api| + expect(api.get("roles")).to have_key(file_type) + end + end + it "knife serve serves up /roles/#{file_type}" do + with_knife_serve do |api| + expect(api.get("roles/#{file_type}")["name"]).to eq(file_type) + end end - ensure - t.kill end end end diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 28773a3c30..353376aa77 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -417,9 +417,8 @@ describe "LWRP" do Chef::Config[:treat_deprecation_warnings_as_errors] = @old_treat_deprecation_warnings_as_errors end - 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 + it "should not load the provider into a const" do + expect(defined?(Chef::Provider::LwrpBuckPasser)).to be_nil end it "should create a method for each action" do @@ -571,55 +570,28 @@ describe "LWRP" do end context "resource class created" do + let(:test_lwrp_class) { @test_lwrp_class } before(:context) do @tmpdir = Dir.mktmpdir("lwrp_test") resource_path = File.join(@tmpdir, "once.rb") IO.write(resource_path, "default_action :create") - - @old_treat_deprecation_warnings_as_errors = Chef::Config[:treat_deprecation_warnings_as_errors] - Chef::Config[:treat_deprecation_warnings_as_errors] = false - Chef::Resource::LWRPBase.build_from_file("lwrp", resource_path, nil) + @test_lwrp_class = Chef::Resource::LWRPBase.build_from_file("lwrp", resource_path, nil) end after(:context) do FileUtils.remove_entry @tmpdir - Chef::Config[:treat_deprecation_warnings_as_errors] = @old_treat_deprecation_warnings_as_errors end - it "should load the resource into a properly-named class" do - expect(Chef::Resource::LwrpOnce).to be_kind_of(Class) - expect(Chef::Resource::LwrpOnce <= Chef::Resource::LWRPBase).to be_truthy + it "should not load the resource into a const" do + expect(defined?(Chef::Resource::LwrpOnce)).to be_nil end - it "get_lwrp(:lwrp_once).new is a Chef::Resource::LwrpOnce" do + it "get_lwrp(:lwrp_once).new is an instance of the LWRP class" do lwrp = get_lwrp(:lwrp_once).new("hi") - expect(lwrp.kind_of?(Chef::Resource::LwrpOnce)).to be_truthy - expect(lwrp.is_a?(Chef::Resource::LwrpOnce)).to be_truthy - expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy - expect(Chef::Resource::LwrpOnce === lwrp).to be_truthy - end - - it "Chef::Resource::LwrpOnce.new is a get_lwrp(:lwrp_once)" do - lwrp = Chef::Resource::LwrpOnce.new("hi") - expect(lwrp.kind_of?(get_lwrp(:lwrp_once))).to be_truthy - expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy + expect(lwrp.kind_of?(test_lwrp_class)).to be_truthy + expect(lwrp.is_a?(test_lwrp_class)).to be_truthy expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy - expect(Chef::Resource::LwrpOnce === lwrp).to be_truthy - end - - it "works even if LwrpOnce exists in the top level" do - module ::LwrpOnce - end - expect(Chef::Resource::LwrpOnce).not_to eq(::LwrpOnce) - end - - it "allows monkey patching of the lwrp through Chef::Resource" do - monkey = Module.new do - def issue_3607 - end - end - Chef::Resource::LwrpOnce.send(:include, monkey) - expect { get_lwrp(:lwrp_once).new("blah").issue_3607 }.not_to raise_error + expect(test_lwrp_class === lwrp).to be_truthy end context "with a subclass of get_lwrp(:lwrp_once)" do @@ -634,12 +606,12 @@ describe "LWRP" do expect(subclass === lwrp).to be_truthy expect(lwrp.class === subclass) end - it "subclass.new is a Chef::Resource::LwrpOnce" do + it "subclass.new is an instance of the LWRP class" do lwrp = subclass.new("hi") - expect(lwrp.kind_of?(Chef::Resource::LwrpOnce)).to be_truthy - expect(lwrp.is_a?(Chef::Resource::LwrpOnce)).to be_truthy - expect(Chef::Resource::LwrpOnce === lwrp).to be_truthy - expect(lwrp.class === Chef::Resource::LwrpOnce) + expect(lwrp.kind_of?(test_lwrp_class)).to be_truthy + expect(lwrp.is_a?(test_lwrp_class)).to be_truthy + expect(test_lwrp_class === lwrp).to be_truthy + expect(lwrp.class === test_lwrp_class) end it "subclass.new is a get_lwrp(:lwrp_once)" do lwrp = subclass.new("hi") @@ -648,55 +620,6 @@ describe "LWRP" do expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy expect(lwrp.class === get_lwrp(:lwrp_once)) end - it "Chef::Resource::LwrpOnce.new is *not* a subclass" do - lwrp = Chef::Resource::LwrpOnce.new("hi") - expect(lwrp.kind_of?(subclass)).to be_falsey - expect(lwrp.is_a?(subclass)).to be_falsey - expect(subclass === lwrp.class).to be_falsey - expect(subclass === Chef::Resource::LwrpOnce).to be_falsey - end - it "get_lwrp(:lwrp_once).new is *not* a subclass" do - lwrp = get_lwrp(:lwrp_once).new("hi") - expect(lwrp.kind_of?(subclass)).to be_falsey - expect(lwrp.is_a?(subclass)).to be_falsey - expect(subclass === lwrp.class).to be_falsey - expect(subclass === get_lwrp(:lwrp_once)).to be_falsey - end - end - - context "with a subclass of Chef::Resource::LwrpOnce" do - let(:subclass) do - Class.new(Chef::Resource::LwrpOnce) - end - - it "subclass.new is a subclass" do - lwrp = subclass.new("hi") - expect(lwrp.kind_of?(subclass)).to be_truthy - expect(lwrp.is_a?(subclass)).to be_truthy - expect(subclass === lwrp).to be_truthy - expect(lwrp.class === subclass) - end - it "subclass.new is a Chef::Resource::LwrpOnce" do - lwrp = subclass.new("hi") - expect(lwrp.kind_of?(Chef::Resource::LwrpOnce)).to be_truthy - expect(lwrp.is_a?(Chef::Resource::LwrpOnce)).to be_truthy - expect(Chef::Resource::LwrpOnce === lwrp).to be_truthy - expect(lwrp.class === Chef::Resource::LwrpOnce) - end - it "subclass.new is a get_lwrp(:lwrp_once)" do - lwrp = subclass.new("hi") - expect(lwrp.kind_of?(get_lwrp(:lwrp_once))).to be_truthy - expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy - expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy - expect(lwrp.class === get_lwrp(:lwrp_once)) - end - it "Chef::Resource::LwrpOnce.new is *not* a subclass" do - lwrp = Chef::Resource::LwrpOnce.new("hi") - expect(lwrp.kind_of?(subclass)).to be_falsey - expect(lwrp.is_a?(subclass)).to be_falsey - expect(subclass === lwrp.class).to be_falsey - expect(subclass === Chef::Resource::LwrpOnce).to be_falsey - end it "get_lwrp(:lwrp_once).new is *not* a subclass" do lwrp = get_lwrp(:lwrp_once).new("hi") expect(lwrp.kind_of?(subclass)).to be_falsey |