summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb2
-rw-r--r--spec/integration/recipes/resource_definition_spec.rb9
-rw-r--r--spec/support/lib/chef/resource/cat.rb2
-rw-r--r--spec/support/lib/chef/resource/one_two_three_four.rb2
-rw-r--r--spec/support/lib/chef/resource/with_state.rb2
-rw-r--r--spec/support/lib/chef/resource/zen_follower.rb2
-rw-r--r--spec/support/lib/chef/resource/zen_master.rb2
-rw-r--r--spec/unit/recipe_spec.rb4
-rw-r--r--spec/unit/resource_spec.rb14
9 files changed, 27 insertions, 12 deletions
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index 3d31b87ffb..c79c20cd7d 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -58,7 +58,6 @@ describe "Recipe DSL methods" do
@allowed_actions = [ :create ]
@action = :create
end
- resource_name 'backcompat_thingy'
end
class Chef::Provider::BackcompatThingy < Chef::Provider
def load_current_resource
@@ -84,6 +83,7 @@ describe "Recipe DSL methods" do
before(:context) {
class RecipeDSLSpecNamespace::BackcompatThingy < BaseThingy
+ provides :backcompat_thingy
resource_name :backcompat_thingy
end
diff --git a/spec/integration/recipes/resource_definition_spec.rb b/spec/integration/recipes/resource_definition_spec.rb
index da92bb18fa..4e5bc53428 100644
--- a/spec/integration/recipes/resource_definition_spec.rb
+++ b/spec/integration/recipes/resource_definition_spec.rb
@@ -3,13 +3,10 @@ require 'support/shared/integration/integration_helper'
describe "Resource definition" do
include IntegrationSupport
- context "With a resource with no resource_name or provides line" do
- before do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- end
-
+ context "With a resource with only provides lines and no resource_name" do
before(:context) {
- class Chef::Resource::ResourceDefinitionNoNameTest < Chef::Resource
+ class ResourceDefinitionNoNameTest < Chef::Resource
+ provides :resource_definition_no_name_test
end
}
it "Creating said resource with the resource builder fails with an exception" do
diff --git a/spec/support/lib/chef/resource/cat.rb b/spec/support/lib/chef/resource/cat.rb
index ac8ad2953f..9bfaebf07b 100644
--- a/spec/support/lib/chef/resource/cat.rb
+++ b/spec/support/lib/chef/resource/cat.rb
@@ -19,7 +19,7 @@
class Chef
class Resource
class Cat < Chef::Resource
- resource_name :cat
+ use_automatic_resource_name
attr_accessor :action
diff --git a/spec/support/lib/chef/resource/one_two_three_four.rb b/spec/support/lib/chef/resource/one_two_three_four.rb
index 52fe8be54d..4543744a28 100644
--- a/spec/support/lib/chef/resource/one_two_three_four.rb
+++ b/spec/support/lib/chef/resource/one_two_three_four.rb
@@ -19,7 +19,7 @@
class Chef
class Resource
class OneTwoThreeFour < Chef::Resource
- resource_name :one_two_three_four
+ use_automatic_resource_name
attr_reader :i_can_count
diff --git a/spec/support/lib/chef/resource/with_state.rb b/spec/support/lib/chef/resource/with_state.rb
index 91051cca58..efff2e7c12 100644
--- a/spec/support/lib/chef/resource/with_state.rb
+++ b/spec/support/lib/chef/resource/with_state.rb
@@ -22,7 +22,7 @@ require 'chef/json_compat'
class Chef
class Resource
class WithState < Chef::Resource
- resource_name :with_state
+ use_automatic_resource_name
attr_accessor :state
end
diff --git a/spec/support/lib/chef/resource/zen_follower.rb b/spec/support/lib/chef/resource/zen_follower.rb
index bbeeeaaeb7..90d33e6039 100644
--- a/spec/support/lib/chef/resource/zen_follower.rb
+++ b/spec/support/lib/chef/resource/zen_follower.rb
@@ -21,7 +21,7 @@ require 'chef/json_compat'
class Chef
class Resource
class ZenFollower < Chef::Resource
- resource_name :zen_follower
+ use_automatic_resource_name
provides :follower, platform: "zen"
diff --git a/spec/support/lib/chef/resource/zen_master.rb b/spec/support/lib/chef/resource/zen_master.rb
index 8f3ff7b72d..ed5b1b3add 100644
--- a/spec/support/lib/chef/resource/zen_master.rb
+++ b/spec/support/lib/chef/resource/zen_master.rb
@@ -22,7 +22,7 @@ require 'chef/json_compat'
class Chef
class Resource
class ZenMaster < Chef::Resource
- resource_name :zen_master
+ use_automatic_resource_name
attr_reader :peace
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 9c4fb49497..59d05298c3 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -121,6 +121,7 @@ describe Chef::Recipe do
it "locate resource for particular platform" do
ShaunTheSheep = Class.new(Chef::Resource)
+ ShaunTheSheep.use_automatic_resource_name
ShaunTheSheep.provides :laughter, :on_platforms => ["television"]
node.automatic[:platform] = "television"
node.automatic[:platform_version] = "123"
@@ -131,6 +132,7 @@ describe Chef::Recipe do
it "locate a resource for all platforms" do
YourMom = Class.new(Chef::Resource)
+ YourMom.use_automatic_resource_name
YourMom.provides :love_and_caring
res = recipe.love_and_caring "mommy"
expect(res.name).to eql("mommy")
@@ -141,8 +143,10 @@ describe Chef::Recipe do
before do
node.automatic[:platform] = "nbc_sports"
Sounders = Class.new(Chef::Resource)
+ Sounders.use_automatic_resource_name
Sounders.provides :football, platform: "nbc_sports"
TottenhamHotspur = Class.new(Chef::Resource)
+ TottenhamHotspur.use_automatic_resource_name
TottenhamHotspur.provides :football, platform: "nbc_sports"
end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 2e0a88f555..bc5567b73a 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -399,6 +399,20 @@ describe Chef::Resource do
expect(r.resource_name).to eq :blah
expect(r.declared_type).to eq :d
end
+ it "use_automatic_resource_name yields a resource name from the class name" do
+ class SelfResourceNameTestBlahDBlah4 < Chef::Resource
+ use_automatic_resource_name
+ end
+
+ c = SelfResourceNameTestBlahDBlah4
+
+ r = c.new('hi')
+ r.declared_type = :d
+ expect(c.resource_name).to eq :self_resource_name_test_blah_d_blah4
+ expect(r.resource_name).to eq :self_resource_name_test_blah_d_blah4
+ expect(r.declared_type).to eq :d
+
+ end
end
describe "is" do