summaryrefslogtreecommitdiff
path: root/spec/integration
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-03-03 21:12:50 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2020-03-03 21:15:06 -0800
commit39a1e0f0bea5103924b21400f4aeb890dffa405b (patch)
tree4e919ad41ca2776108b55b11fc80eb51ee3fb3bc /spec/integration
parent633c4445e00f3174d156ac69a05be117a3fd0456 (diff)
downloadchef-39a1e0f0bea5103924b21400f4aeb890dffa405b.tar.gz
Remove the canonical DSL
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/integration')
-rw-r--r--spec/integration/recipes/lwrp_inline_resources_spec.rb6
-rw-r--r--spec/integration/recipes/noop_resource_spec.rb2
-rw-r--r--spec/integration/recipes/provider_choice.rb2
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb188
-rw-r--r--spec/integration/recipes/resource_action_spec.rb27
-rw-r--r--spec/integration/recipes/resource_converge_if_changed_spec.rb2
-rw-r--r--spec/integration/recipes/resource_load_spec.rb4
7 files changed, 70 insertions, 161 deletions
diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb
index b96fa1d67d..b41b9342b0 100644
--- a/spec/integration/recipes/lwrp_inline_resources_spec.rb
+++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb
@@ -20,7 +20,7 @@ describe "LWRPs with inline resources" do
context "with a use_inline_resources provider with 'def action_a' instead of action :a" do
class LwrpInlineResourcesTest < Chef::Resource
- resource_name :lwrp_inline_resources_test
+ provides :lwrp_inline_resources_test
allowed_actions :a, :nothing
default_action :a
property :ran_a
@@ -46,8 +46,8 @@ describe "LWRPs with inline resources" do
context "with an inline resource with a property that shadows the enclosing provider's property" do
class LwrpShadowedPropertyTest < Chef::Resource
+ provides :lwrp_shadowed_property_test
PATH = ::File.join(Dir.tmpdir, "shadow-property.txt")
- use_automatic_resource_name
allowed_actions :fiddle
property :content
action :fiddle do
@@ -73,7 +73,7 @@ describe "LWRPs with inline resources" do
context "with an inline_resources provider with two actions, one calling the other" do
class LwrpInlineResourcesTest2 < Chef::Resource
- resource_name :lwrp_inline_resources_test2
+ provides :lwrp_inline_resources_test2
allowed_actions :a, :b, :nothing
default_action :b
property :ran_a
diff --git a/spec/integration/recipes/noop_resource_spec.rb b/spec/integration/recipes/noop_resource_spec.rb
index db6b668553..8e15050704 100644
--- a/spec/integration/recipes/noop_resource_spec.rb
+++ b/spec/integration/recipes/noop_resource_spec.rb
@@ -6,7 +6,7 @@ describe "Resources with a no-op provider" do
context "with noop provider providing foo" do
before(:each) do
class NoOpFoo < Chef::Resource
- resource_name "hi_there"
+ provides "hi_there"
default_action :update
end
Chef::Provider::Noop.provides :hi_there
diff --git a/spec/integration/recipes/provider_choice.rb b/spec/integration/recipes/provider_choice.rb
index dea58230db..66aa58a432 100644
--- a/spec/integration/recipes/provider_choice.rb
+++ b/spec/integration/recipes/provider_choice.rb
@@ -16,6 +16,8 @@ describe "Recipe DSL methods" do
context "And class Chef::Provider::ProviderThingy with no provides" do
before :context do
class Chef::Provider::ProviderThingy < Chef::Provider
+ provides :provider_thingy
+
def load_current_resource; end
def action_create
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index 766752ac13..e56ffa87bf 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -15,7 +15,7 @@ describe "Recipe DSL methods" do
before(:each) do
class BaseThingy < Chef::Resource
- resource_name "base_thingy"
+ provides :base_thingy
default_action :create
class<<self
@@ -67,7 +67,6 @@ describe "Recipe DSL methods" do
context "nameless resources" do
before(:each) do
class NamelessThingy < BaseThingy
- resource_name :nameless_thingy
provides :nameless_thingy
property :name, String, default: ""
@@ -124,7 +123,7 @@ describe "Recipe DSL methods" do
before(:each) do
class AnotherNoNameThingy < BaseThingy
- resource_name :another_thingy_name
+ provides :another_thingy_name
end
end
@@ -148,8 +147,8 @@ describe "Recipe DSL methods" do
before(:each) do
class AnotherNoNameThingy2 < BaseThingy
- resource_name :another_thingy_name2
- resource_name :another_thingy_name3
+ provides :another_thingy_name2
+ provides :another_thingy_name3
end
end
@@ -160,10 +159,12 @@ describe "Recipe DSL methods" do
end.to raise_error(NoMethodError)
end
- it "another_thingy_name2 does not work" do
- expect_converge do
+ it "another_thingy_name2 works" do
+ recipe = converge do
another_thingy_name2("blah") {}
- end.to raise_error(NoMethodError)
+ end
+ expect(recipe.logged_warnings).to eq ""
+ expect(BaseThingy.created_resource).to eq(AnotherNoNameThingy2)
end
it "yet_another_thingy_name3 works" do
@@ -180,7 +181,7 @@ describe "Recipe DSL methods" do
before(:each) do
class AnotherNoNameThingy3 < BaseThingy
- resource_name :another_no_name_thingy_3
+ provides :another_no_name_thingy_3
provides :another_no_name_thingy3, os: "blarghle"
end
@@ -209,7 +210,7 @@ describe "Recipe DSL methods" do
before(:each) do
class AnotherNoNameThingy4 < BaseThingy
- resource_name :another_no_name_thingy_4
+ provides :another_no_name_thingy_4
provides :another_no_name_thingy4, os: "blarghle"
provides :another_no_name_thingy4, platform_family: "foo"
end
@@ -249,7 +250,7 @@ describe "Recipe DSL methods" do
before(:each) do
class AnotherNoNameThingy5 < BaseThingy
- resource_name :another_thingy_name_for_another_no_name_thingy5
+ provides :another_thingy_name_for_another_no_name_thingy5
provides :another_no_name_thingy5, os: "blarghle"
end
@@ -287,7 +288,7 @@ describe "Recipe DSL methods" do
class AnotherNoNameThingy6 < BaseThingy
provides :another_no_name_thingy6, os: "blarghle"
- resource_name :another_thingy_name_for_another_no_name_thingy6
+ provides :another_thingy_name_for_another_no_name_thingy6
end
end
@@ -323,18 +324,20 @@ describe "Recipe DSL methods" do
before(:each) do
class AnotherNoNameThingy7 < BaseThingy
- resource_name :another_thingy_name_for_another_no_name_thingy7
+ provides :another_thingy_name_for_another_no_name_thingy7
provides :another_thingy_name_for_another_no_name_thingy7, os: "blarghle"
end
end
- it "and os = linux, another_thingy_name_for_another_no_name_thingy7 does not work" do
- expect_converge do
+ it "and os = linux, another_thingy_name_for_another_no_name_thingy7 works" do
+ recipe = converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "linux"
another_thingy_name_for_another_no_name_thingy7("blah") {}
- end.to raise_error(Chef::Exceptions::NoSuchResourceType)
+ end
+ expect(recipe.logged_warnings).to eq ""
+ expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy7)
end
it "and os = blarghle, another_thingy_name_for_another_no_name_thingy7 works" do
@@ -356,43 +359,6 @@ describe "Recipe DSL methods" do
end
end
- # opposite order from the previous test (provides, then resource_name)
- context "with a resource named AnotherNoNameThingy8, a provides with a new resource name, and resource_name with that new resource name" do
- before(:each) do
-
- class AnotherNoNameThingy8 < BaseThingy
- provides :another_thingy_name_for_another_no_name_thingy8, os: "blarghle"
- resource_name :another_thingy_name_for_another_no_name_thingy8
- end
-
- end
-
- it "and os = linux, another_thingy_name_for_another_no_name_thingy8 does not work" do
- expect_converge do
- # this is an ugly way to test, make Cheffish expose node attrs
- run_context.node.automatic[:os] = "linux"
- another_thingy_name_for_another_no_name_thingy8("blah") {}
- end.to raise_error(Chef::Exceptions::NoSuchResourceType)
- end
-
- it "and os = blarghle, another_thingy_name_for_another_no_name_thingy8 works" do
- recipe = converge do
- # this is an ugly way to test, make Cheffish expose node attrs
- run_context.node.automatic[:os] = "blarghle"
- another_thingy_name_for_another_no_name_thingy8("blah") {}
- end
- expect(recipe.logged_warnings).to eq ""
- expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy8)
- end
-
- it "the old resource name does not work" do
- expect_converge do
- # this is an ugly way to test, make Cheffish expose node attrs
- run_context.node.automatic[:os] = "linux"
- another_thingy_name8("blah") {}
- end.to raise_error(NoMethodError)
- end
- end
end
end
@@ -401,7 +367,7 @@ describe "Recipe DSL methods" do
before(:each) do
class RecipeDSLSpecNamespace::MySupplier < BaseThingy
- resource_name :hemlock
+ provides :hemlock
end
end
@@ -424,7 +390,7 @@ describe "Recipe DSL methods" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy3 < BaseThingy
- resource_name :thingy3
+ provides :thingy3
end
end
@@ -440,7 +406,7 @@ describe "Recipe DSL methods" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
- resource_name :thingy3
+ provides :thingy3
end
end
@@ -468,7 +434,7 @@ describe "Recipe DSL methods" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy5 < BaseThingy
- resource_name :thingy5
+ provides :thingy5
provides :thingy5reverse
provides :thingy5_2
provides :thingy5_2reverse
@@ -487,7 +453,7 @@ describe "Recipe DSL methods" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy6 < BaseThingy
- resource_name :thingy6
+ provides :thingy6
provides :thingy5
end
@@ -508,14 +474,14 @@ describe "Recipe DSL methods" do
end
it "resource_matching_short_name returns Thingy6" do
- expect(Chef::Resource.resource_matching_short_name(:thingy5)).to eq RecipeDSLSpecNamespace::Thingy5
+ expect(Chef::Resource.resource_matching_short_name(:thingy5)).to eq RecipeDSLSpecNamespace::Thingy6
end
context "and AThingy5 provides :thingy5reverse" do
before(:each) do
class RecipeDSLSpecNamespace::AThingy5 < BaseThingy
- resource_name :thingy5reverse
+ provides :thingy5reverse
end
end
@@ -533,7 +499,7 @@ describe "Recipe DSL methods" do
module ZRecipeDSLSpecNamespace
class Thingy5 < BaseThingy
- resource_name :thingy5_2
+ provides :thingy5_2
end
end
@@ -552,7 +518,7 @@ describe "Recipe DSL methods" do
module ARecipeDSLSpecNamespace
class Thingy5 < BaseThingy
- resource_name :thingy5_2reverse
+ provides :thingy5_2reverse
end
end
@@ -571,7 +537,7 @@ describe "Recipe DSL methods" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy3 < BaseThingy
- resource_name :thingy3
+ provides :thingy3
end
end
@@ -587,7 +553,7 @@ describe "Recipe DSL methods" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
- resource_name :thingy3
+ provides :thingy3
end
end
@@ -614,7 +580,7 @@ describe "Recipe DSL methods" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
- resource_name :thingy3
+ provides :thingy3
end
end
@@ -644,7 +610,7 @@ describe "Recipe DSL methods" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy7 < BaseThingy
- resource_name :thingy7
+ provides :thingy7
provides :thingy8
end
@@ -654,7 +620,7 @@ describe "Recipe DSL methods" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy8 < BaseThingy
- resource_name :thingy8
+ provides :thingy8
end
end
@@ -683,7 +649,7 @@ describe "Recipe DSL methods" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy12 < BaseThingy
- resource_name :thingy12
+ provides :thingy12
provides :twizzle
provides :twizzle2
end
@@ -715,12 +681,12 @@ describe "Recipe DSL methods" do
context "with platform-specific resources 'my_super_thingy_foo' and 'my_super_thingy_bar'" do
before(:each) do
class MySuperThingyFoo < BaseThingy
- resource_name :my_super_thingy_foo
+ provides :my_super_thingy_foo
provides :my_super_thingy, platform: "foo"
end
class MySuperThingyBar < BaseThingy
- resource_name :my_super_thingy_bar
+ provides :my_super_thingy_bar
provides :my_super_thingy, platform: "bar"
end
end
@@ -761,7 +727,7 @@ describe "Recipe DSL methods" do
context "when Thingy10 provides :thingy10" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy10 < BaseThingy
- resource_name :thingy10
+ provides :thingy10
end
end
@@ -776,7 +742,7 @@ describe "Recipe DSL methods" do
context "when Thingy11 provides :thingy11" do
before(:each) do
class RecipeDSLSpecNamespace::Thingy11 < BaseThingy
- resource_name :thingy10
+ provides :thingy10
end
end
@@ -801,7 +767,7 @@ describe "Recipe DSL methods" do
def self.inspect; name.inspect; end
end
- result.resource_name two_classes_one_dsl
+ result.provides two_classes_one_dsl
result
end
before { resource_class } # pull on it so it gets defined before the recipe runs
@@ -817,7 +783,7 @@ describe "Recipe DSL methods" do
def self.inspect; name.inspect; end
end
- result.resource_name two_classes_one_dsl
+ result.provides two_classes_one_dsl
result
end
before { resource_class_a } # pull on it so it gets defined before the recipe runs
@@ -847,7 +813,7 @@ describe "Recipe DSL methods" do
def self.inspect; name.inspect; end
end
- result.resource_name two_classes_one_dsl
+ result.provides two_classes_one_dsl
result
end
before { resource_class_z } # pull on it so it gets defined before the recipe runs
@@ -882,25 +848,6 @@ describe "Recipe DSL methods" do
it "resource_matching_short_name returns Z" do
expect(Chef::Resource.resource_matching_short_name(two_classes_one_dsl)).to eq resource_class_z
end
-
- context "when Z provides(:two_classes_one_dsl) { false }" do
- before do
- resource_class_z.provides(two_classes_one_dsl) { false }
- end
-
- it "two_classes_one_dsl resolves to B (picks the next thing in the priority array)" do
- temp_two_classes_one_dsl = two_classes_one_dsl
- recipe = converge do
- instance_eval("#{temp_two_classes_one_dsl} 'blah'")
- end
- expect(recipe.logged_warnings).to eq ""
- expect(BaseThingy.created_resource).to eq resource_class
- end
-
- it "resource_matching_short_name returns B" do
- expect(Chef::Resource.resource_matching_short_name(two_classes_one_dsl)).to eq resource_class
- end
- end
end
context "and priority arrays [ B ] and [ Z ]" do
@@ -921,52 +868,7 @@ describe "Recipe DSL methods" do
it "resource_matching_short_name returns Z" do
expect(Chef::Resource.resource_matching_short_name(two_classes_one_dsl)).to eq resource_class_z
end
-
- context "when Z provides(:two_classes_one_dsl) { false }" do
- before do
- resource_class_z.provides(two_classes_one_dsl) { false }
- end
-
- it "two_classes_one_dsl resolves to B (picks the first match from the other priority array)" do
- temp_two_classes_one_dsl = two_classes_one_dsl
- recipe = converge do
- instance_eval("#{temp_two_classes_one_dsl} 'blah'")
- end
- expect(recipe.logged_warnings).to eq ""
- expect(BaseThingy.created_resource).to eq resource_class
- end
-
- it "resource_matching_short_name returns B" do
- expect(Chef::Resource.resource_matching_short_name(two_classes_one_dsl)).to eq resource_class
- end
- end
end
-
- context "and a priority array [ Z ]" do
- before do
- Chef.set_resource_priority_array(two_classes_one_dsl, [ resource_class_z ])
- end
-
- context "when Z provides(:two_classes_one_dsl) { false }" do
- before do
- resource_class_z.provides(two_classes_one_dsl) { false }
- end
-
- it "two_classes_one_dsl resolves to B (picks the first match outside the priority array)" do
- temp_two_classes_one_dsl = two_classes_one_dsl
- recipe = converge do
- instance_eval("#{temp_two_classes_one_dsl} 'blah'")
- end
- expect(recipe.logged_warnings).to eq ""
- expect(BaseThingy.created_resource).to eq resource_class
- end
-
- it "resource_matching_short_name returns B" do
- expect(Chef::Resource.resource_matching_short_name(two_classes_one_dsl)).to eq resource_class
- end
- end
- end
-
end
context "and a provider named 'B' which provides :two_classes_one_dsl" do
@@ -1113,7 +1015,7 @@ describe "Recipe DSL methods" do
def self.inspect; name.inspect; end
end
- result.resource_name two_classes_one_dsl
+ result.provides two_classes_one_dsl
result.provides two_classes_one_dsl, os: "blarghle"
result
end
@@ -1138,7 +1040,7 @@ describe "Recipe DSL methods" do
instance_eval("#{temp_two_classes_one_dsl} 'blah' do; end")
end
expect(recipe.logged_warnings).to eq ""
- expect(BaseThingy.created_resource).to eq resource_class
+ expect(BaseThingy.created_resource).to eq resource_class_blarghle
end
end
end
@@ -1160,7 +1062,7 @@ describe "Recipe DSL methods" do
context "with resource_name :my_resource" do
before do
- resource_class.resource_name my_resource
+ resource_class.provides my_resource
end
context "with provides? returning true to my_resource" do
@@ -1311,7 +1213,7 @@ describe "Recipe DSL methods" do
context "with UTF-8 provides" do
before(:each) do
class UTF8Thingy < BaseThingy
- resource_name :Straße
+ provides :Straße
provides :Straße
end
end
diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb
index c8da9196ca..802d4976b7 100644
--- a/spec/integration/recipes/resource_action_spec.rb
+++ b/spec/integration/recipes/resource_action_spec.rb
@@ -1,7 +1,7 @@
require "support/shared/integration/integration_helper"
class NoActionJackson < Chef::Resource
- use_automatic_resource_name
+ provides :no_action_jackson
def foo(value = nil)
@foo = value if value
@@ -14,7 +14,7 @@ class NoActionJackson < Chef::Resource
end
class WeirdActionJackson < Chef::Resource
- use_automatic_resource_name
+ provides :weird_action_jackson
class <<self
attr_accessor :action_was
@@ -163,7 +163,8 @@ module ResourceActionSpec
context "With resource 'action_jackson'" do
class ActionJackson < Chef::Resource
- use_automatic_resource_name
+ provides :action_jackson
+
def foo(value = nil)
@foo = value if value
@foo
@@ -256,7 +257,7 @@ module ResourceActionSpec
context "And 'action_jackgrandson' inheriting from ActionJackson and changing nothing" do
before(:each) do
class ActionJackgrandson < ActionJackson
- use_automatic_resource_name
+ provides :action_jackgrandson
end
end
@@ -267,7 +268,7 @@ module ResourceActionSpec
context "And 'action_jackalope' inheriting from ActionJackson with an extra attribute, action and custom method" do
class ActionJackalope < ActionJackson
- use_automatic_resource_name
+ provides :action_jackalope
def foo(value = nil)
@foo = "#{value}alope" if value
@@ -380,7 +381,7 @@ module ResourceActionSpec
context "With a resource with a set_or_return property named group (same name as a resource)" do
class ResourceActionSpecWithGroupAction < Chef::Resource
- resource_name :resource_action_spec_set_group_to_nil
+ provides :resource_action_spec_set_group_to_nil
action :set_group_to_nil do
# Access x during converge to ensure that we emit no warnings there
resource_action_spec_with_group "hi" do
@@ -391,7 +392,7 @@ module ResourceActionSpec
end
class ResourceActionSpecWithGroup < Chef::Resource
- resource_name :resource_action_spec_with_group
+ provides :resource_action_spec_with_group
def group(value = nil)
set_or_return(:group, value, {})
end
@@ -408,7 +409,8 @@ module ResourceActionSpec
context "When a resource has a property with the same name as another resource" do
class HasPropertyNamedTemplate < Chef::Resource
- use_automatic_resource_name
+ provides :has_property_named_template
+
property :template
action :create do
template "x" do
@@ -420,7 +422,8 @@ module ResourceActionSpec
context "When a resource declares methods in action_class" do
class DeclaresActionClassMethods < Chef::Resource
- use_automatic_resource_name
+ provides :declares_action_class_methods
+
property :x
action_class do
def a
@@ -452,7 +455,8 @@ module ResourceActionSpec
context "And a subclass overrides a method with an action_class block" do
class DeclaresActionClassMethodsToo < DeclaresActionClassMethods
- use_automatic_resource_name
+ provides :declares_action_class_methods_too
+
action_class do
def a
5
@@ -477,7 +481,8 @@ module ResourceActionSpec
context "And a subclass overrides a method with class_eval" do
# this tests inheritance with *only* an action_class accessor that does not declare a block
class DeclaresActionClassMethodsToo < DeclaresActionClassMethods
- use_automatic_resource_name
+ provides :declares_action_class_methods_too
+
action_class.class_eval <<-EOM
def a
5
diff --git a/spec/integration/recipes/resource_converge_if_changed_spec.rb b/spec/integration/recipes/resource_converge_if_changed_spec.rb
index 97314646d9..24bd1f14ad 100644
--- a/spec/integration/recipes/resource_converge_if_changed_spec.rb
+++ b/spec/integration/recipes/resource_converge_if_changed_spec.rb
@@ -35,7 +35,7 @@ describe "Resource::ActionClass#converge_if_changed" do
@converged = 0
end
end
- result.resource_name resource_name
+ result.provides resource_name
result
end
let(:converged_recipe) { converge(converge_recipe) }
diff --git a/spec/integration/recipes/resource_load_spec.rb b/spec/integration/recipes/resource_load_spec.rb
index 79df1d6478..3ca71c3a03 100644
--- a/spec/integration/recipes/resource_load_spec.rb
+++ b/spec/integration/recipes/resource_load_spec.rb
@@ -35,7 +35,7 @@ describe "Resource.load_current_value" do
new_resource.class.created_x = new_resource.x
end
end
- result.resource_name resource_name
+ result.provides resource_name
result
end
@@ -126,7 +126,7 @@ describe "Resource.load_current_value" do
r = Class.new(resource_class) do
property :y, default: lazy { "default_y #{Namer.incrementing_value}" }
end
- r.resource_name subresource_name
+ r.provides subresource_name
r
end