summaryrefslogtreecommitdiff
path: root/spec/unit/resource_spec.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-03-08 14:16:39 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2017-03-08 14:16:39 -0800
commit4650185d366874c175bd043d11fad6244ba33e6f (patch)
treecacaeed332ba97b480833a82da218e9328234297 /spec/unit/resource_spec.rb
parent416ab0c10f510c7d51d4c6c35741d0cca2a0bc21 (diff)
downloadchef-4650185d366874c175bd043d11fad6244ba33e6f.tar.gz
Chef-13: Chef::Resource cleanup
most of this deletes useless old code. the change to lookup_provider_constant changes to more strictly stop using class name based lookups and to go through the resource resolver and provider resolver. as a result in order to find the provider class for a given dsl name you have to go through the resource resolver to find the resource in order to be able to pass a resource instance through the provider resolver. since the provider resolver api passes resources into blocks passed into provides api you must construct a resource instance. that means that providers need to be associated with resources in order to be looked up (which makes sense in Real Life(tm) use of Chef, but breaks quite a few lazy tests we had where we constructed providers without doing the work of wrapping them in a resource. note that as the deploy resource shows this filters into a changed behavior of the `provider` syntax where before `provider :revision` would look up Chef::Provider::Deploy::Revision via class-name based magic. this breaks that API so that `provider :deploy_revision` is used instead -- the symbol (or string) there is turned into a resource first via the Chef::ResourceResolver and then looked up via the Chef::ProviderResolver into Chef::Provider::Deploy::Revision. this is a breaking change but is also a bug fix so that the symbol here goes through the same lookup that you get when you type it in the DSL. i had considered implementing a lookup from a resource_name symbol to a provider, but in looking at how to implement that in the ProviderResolver the issue is that we really need to have a resource instance order to pass to the ProviderResolver. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/unit/resource_spec.rb')
-rw-r--r--spec/unit/resource_spec.rb49
1 files changed, 2 insertions, 47 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 481a379743..df8ae3100a 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -231,14 +231,6 @@ describe Chef::Resource do
end
end
- describe "noop" do
- it "should accept true or false for noop" do
- expect { resource.noop true }.not_to raise_error
- expect { resource.noop false }.not_to raise_error
- expect { resource.noop "eat it" }.to raise_error(ArgumentError)
- end
- end
-
describe "notifies" do
it "should make notified resources appear in the actions hash" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
@@ -450,18 +442,6 @@ describe Chef::Resource do
end
end
- describe "is" do
- it "should return the arguments passed with 'is'" do
- zm = Chef::Resource::ZenMaster.new("coffee")
- expect(zm.is("one", "two", "three")).to eq(%w{one two three})
- end
-
- it "should allow arguments preceded by is to methods" do
- resource.noop(resource.is(true))
- expect(resource.noop).to eql(true)
- end
- end
-
describe "to_json" do
it "should serialize to json" do
json = resource.to_json
@@ -480,7 +460,7 @@ describe Chef::Resource do
it "should include the default in the hash" do
expect(resource.to_hash.keys.sort).to eq([:a, :allowed_actions, :params, :provider, :updated,
:updated_by_last_action, :before,
- :noop, :name, :source_line,
+ :name, :source_line,
:action, :elapsed_time,
:default_guard_interpreter, :guard_interpreter].sort)
expect(resource.to_hash[:name]).to eq "funk"
@@ -492,7 +472,7 @@ describe Chef::Resource do
hash = resource.to_hash
expected_keys = [ :allowed_actions, :params, :provider, :updated,
:updated_by_last_action, :before,
- :noop, :name, :source_line,
+ :name, :source_line,
:action, :elapsed_time,
:default_guard_interpreter, :guard_interpreter ]
expect(hash.keys - expected_keys).to eq([])
@@ -571,31 +551,6 @@ describe Chef::Resource do
end
end
- describe "setting the base provider class for the resource" do
-
- it "defaults to Chef::Provider for the base class" do
- expect(Chef::Resource.provider_base).to eq(Chef::Provider)
- end
-
- it "allows the base provider to be overridden" do
- Chef::Config.treat_deprecation_warnings_as_errors(false)
- class OverrideProviderBaseTest < Chef::Resource
- provider_base Chef::Provider::Package
- end
-
- expect(OverrideProviderBaseTest.provider_base).to eq(Chef::Provider::Package)
- end
-
- it "warns when setting provider_base" do
- expect do
- class OverrideProviderBaseTest2 < Chef::Resource
- provider_base Chef::Provider::Package
- end
- end.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
- end
-
- end
-
it "runs an action by finding its provider, loading the current resource and then running the action" do
skip
end