summaryrefslogtreecommitdiff
path: root/spec/integration/recipes/recipe_dsl_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/integration/recipes/recipe_dsl_spec.rb')
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb87
1 files changed, 29 insertions, 58 deletions
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index db4d158eec..baa3a64660 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -13,7 +13,6 @@ describe "Recipe DSL methods" do
context "with resource 'base_thingy' declared as BaseThingy" do
before(:context) {
-
class BaseThingy < Chef::Resource
resource_name "base_thingy"
default_action :create
@@ -30,6 +29,7 @@ describe "Recipe DSL methods" do
class Provider < Chef::Provider
def load_current_resource
end
+
def action_create
BaseThingy.created_name = new_resource.name
BaseThingy.created_resource = new_resource.class
@@ -41,7 +41,6 @@ describe "Recipe DSL methods" do
# Modules to put stuff in
module RecipeDSLSpecNamespace; end
module RecipeDSLSpecNamespace::Bar; end
-
}
before :each do
@@ -82,19 +81,18 @@ describe "Recipe DSL methods" do
context "with a resource 'backcompat_thingy' declared in Chef::Resource and Chef::Provider" do
before(:context) {
-
class Chef::Resource::BackcompatThingy < Chef::Resource
default_action :create
end
class Chef::Provider::BackcompatThingy < Chef::Provider
def load_current_resource
end
+
def action_create
BaseThingy.created_resource = new_resource.class
BaseThingy.created_provider = self.class
end
end
-
}
it "backcompat_thingy creates a Chef::Resource::BackcompatThingy" do
@@ -107,12 +105,10 @@ describe "Recipe DSL methods" do
context "and another resource 'backcompat_thingy' in BackcompatThingy with 'provides'" do
before(:context) {
-
class RecipeDSLSpecNamespace::BackcompatThingy < BaseThingy
provides :backcompat_thingy
resource_name :backcompat_thingy
end
-
}
it "backcompat_thingy creates a BackcompatThingy" do
@@ -127,10 +123,8 @@ describe "Recipe DSL methods" do
context "with a resource named RecipeDSLSpecNamespace::Bar::BarThingy" do
before(:context) {
-
class RecipeDSLSpecNamespace::Bar::BarThingy < BaseThingy
end
-
}
it "bar_thingy does not work" do
@@ -142,11 +136,9 @@ describe "Recipe DSL methods" do
context "with a resource named Chef::Resource::NoNameThingy with resource_name nil" do
before(:context) {
-
class Chef::Resource::NoNameThingy < BaseThingy
resource_name nil
end
-
}
it "no_name_thingy does not work" do
@@ -158,11 +150,9 @@ describe "Recipe DSL methods" do
context "with a resource named AnotherNoNameThingy with resource_name :another_thingy_name" do
before(:context) {
-
class AnotherNoNameThingy < BaseThingy
resource_name :another_thingy_name
end
-
}
it "another_no_name_thingy does not work" do
@@ -182,12 +172,10 @@ describe "Recipe DSL methods" do
context "with a resource named AnotherNoNameThingy2 with resource_name :another_thingy_name2; resource_name :another_thingy_name3" do
before(:context) {
-
class AnotherNoNameThingy2 < BaseThingy
resource_name :another_thingy_name2
resource_name :another_thingy_name3
end
-
}
it "another_no_name_thingy does not work" do
@@ -214,12 +202,10 @@ describe "Recipe DSL methods" do
context "provides overriding resource_name" do
context "with a resource named AnotherNoNameThingy3 with provides :another_no_name_thingy3, os: 'blarghle'" do
before(:context) {
-
class AnotherNoNameThingy3 < BaseThingy
resource_name :another_no_name_thingy_3
provides :another_no_name_thingy3, os: "blarghle"
end
-
}
it "and os = linux, another_no_name_thingy3 does not work" do
@@ -243,13 +229,11 @@ describe "Recipe DSL methods" do
context "with a resource named AnotherNoNameThingy4 with two provides" do
before(:context) {
-
class AnotherNoNameThingy4 < BaseThingy
resource_name :another_no_name_thingy_4
provides :another_no_name_thingy4, os: "blarghle"
provides :another_no_name_thingy4, platform_family: "foo"
end
-
}
it "and os = linux, another_no_name_thingy4 does not work" do
@@ -283,12 +267,10 @@ describe "Recipe DSL methods" do
context "with a resource named AnotherNoNameThingy5, a different resource_name, and a provides with the original resource_name" do
before(:context) {
-
class AnotherNoNameThingy5 < BaseThingy
resource_name :another_thingy_name_for_another_no_name_thingy5
provides :another_no_name_thingy5, os: "blarghle"
end
-
}
it "and os = linux, another_no_name_thingy5 does not work" do
@@ -320,12 +302,10 @@ describe "Recipe DSL methods" do
context "with a resource named AnotherNoNameThingy6, a provides with the original resource name, and a different resource_name" do
before(:context) {
-
class AnotherNoNameThingy6 < BaseThingy
provides :another_no_name_thingy6, os: "blarghle"
resource_name :another_thingy_name_for_another_no_name_thingy6
end
-
}
it "and os = linux, another_no_name_thingy6 does not work" do
@@ -357,12 +337,10 @@ describe "Recipe DSL methods" do
context "with a resource named AnotherNoNameThingy7, a new resource_name, and provides with that new resource name" do
before(:context) {
-
class AnotherNoNameThingy7 < BaseThingy
resource_name :another_thingy_name_for_another_no_name_thingy7
provides :another_thingy_name_for_another_no_name_thingy7, os: "blarghle"
end
-
}
it "and os = linux, another_thingy_name_for_another_no_name_thingy7 does not work" do
@@ -395,12 +373,10 @@ describe "Recipe DSL methods" do
# 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(:context) {
-
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
-
}
it "and os = linux, another_thingy_name_for_another_no_name_thingy8 does not work" do
@@ -435,11 +411,9 @@ describe "Recipe DSL methods" do
context "provides" do
context "when MySupplier provides :hemlock" do
before(:context) {
-
class RecipeDSLSpecNamespace::MySupplier < BaseThingy
resource_name :hemlock
end
-
}
it "my_supplier does not work in a recipe" do
@@ -458,11 +432,9 @@ describe "Recipe DSL methods" do
context "when Thingy3 has resource_name :thingy3" do
before(:context) {
-
class RecipeDSLSpecNamespace::Thingy3 < BaseThingy
resource_name :thingy3
end
-
}
it "thingy3 works in a recipe" do
@@ -474,11 +446,9 @@ describe "Recipe DSL methods" do
context "and Thingy4 has resource_name :thingy3" do
before(:context) {
-
class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
resource_name :thingy3
end
-
}
it "thingy3 works in a recipe and yields Thingy3 (the alphabetical one)" do
@@ -502,14 +472,12 @@ describe "Recipe DSL methods" do
context "when Thingy5 has resource_name :thingy5 and provides :thingy5reverse, :thingy5_2 and :thingy5_2reverse" do
before(:context) {
-
class RecipeDSLSpecNamespace::Thingy5 < BaseThingy
resource_name :thingy5
provides :thingy5reverse
provides :thingy5_2
provides :thingy5_2reverse
end
-
}
it "thingy5 works in a recipe" do
@@ -521,12 +489,10 @@ describe "Recipe DSL methods" do
context "and Thingy6 provides :thingy5" do
before(:context) {
-
class RecipeDSLSpecNamespace::Thingy6 < BaseThingy
resource_name :thingy6
provides :thingy5
end
-
}
it "thingy6 works in a recipe and yields Thingy6" do
@@ -549,11 +515,9 @@ describe "Recipe DSL methods" do
context "and AThingy5 provides :thingy5reverse" do
before(:context) {
-
class RecipeDSLSpecNamespace::AThingy5 < BaseThingy
resource_name :thingy5reverse
end
-
}
it "thingy5reverse works in a recipe and yields AThingy5 (the alphabetical one)" do
@@ -566,13 +530,11 @@ describe "Recipe DSL methods" do
context "and ZRecipeDSLSpecNamespace::Thingy5 provides :thingy5_2" do
before(:context) {
-
module ZRecipeDSLSpecNamespace
class Thingy5 < BaseThingy
resource_name :thingy5_2
end
end
-
}
it "thingy5_2 works in a recipe and yields the RecipeDSLSpaceNamespace one (the alphabetical one)" do
@@ -585,13 +547,11 @@ describe "Recipe DSL methods" do
context "and ARecipeDSLSpecNamespace::Thingy5 provides :thingy5_2" do
before(:context) {
-
module ARecipeDSLSpecNamespace
class Thingy5 < BaseThingy
resource_name :thingy5_2reverse
end
end
-
}
it "thingy5_2reverse works in a recipe and yields the ARecipeDSLSpaceNamespace one (the alphabetical one)" do
@@ -605,11 +565,9 @@ describe "Recipe DSL methods" do
context "when Thingy3 has resource_name :thingy3" do
before(:context) {
-
class RecipeDSLSpecNamespace::Thingy3 < BaseThingy
resource_name :thingy3
end
-
}
it "thingy3 works in a recipe" do
@@ -621,11 +579,9 @@ describe "Recipe DSL methods" do
context "and Thingy4 has resource_name :thingy3" do
before(:context) {
-
class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
resource_name :thingy3
end
-
}
it "thingy3 works in a recipe and yields Thingy3 (the alphabetical one)" do
@@ -648,11 +604,9 @@ describe "Recipe DSL methods" do
context "and Thingy4 has resource_name :thingy3" do
before(:context) {
-
class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
resource_name :thingy3
end
-
}
it "thingy3 works in a recipe and yields Thingy3 (the alphabetical one)" do
@@ -673,26 +627,21 @@ describe "Recipe DSL methods" do
end
end
end
-
end
context "when Thingy7 provides :thingy8" do
before(:context) {
-
class RecipeDSLSpecNamespace::Thingy7 < BaseThingy
resource_name :thingy7
provides :thingy8
end
-
}
context "and Thingy8 has resource_name :thingy8" do
before(:context) {
-
class RecipeDSLSpecNamespace::Thingy8 < BaseThingy
resource_name :thingy8
end
-
}
it "thingy7 works in a recipe and yields Thingy7" do
@@ -717,13 +666,11 @@ describe "Recipe DSL methods" do
context "when Thingy12 provides :thingy12, :twizzle and :twizzle2" do
before(:context) {
-
class RecipeDSLSpecNamespace::Thingy12 < BaseThingy
resource_name :thingy12
provides :twizzle
provides :twizzle2
end
-
}
it "thingy12 works in a recipe and yields Thingy12" do
@@ -832,7 +779,9 @@ describe "Recipe DSL methods" do
def self.name
"B"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result.resource_name two_classes_one_dsl
@@ -846,7 +795,9 @@ describe "Recipe DSL methods" do
def self.name
"A"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result.resource_name two_classes_one_dsl
@@ -874,7 +825,9 @@ describe "Recipe DSL methods" do
def self.name
"Z"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result.resource_name two_classes_one_dsl
@@ -996,7 +949,6 @@ describe "Recipe DSL methods" do
end
end
end
-
end
context "and a provider named 'B' which provides :two_classes_one_dsl" do
@@ -1009,7 +961,9 @@ describe "Recipe DSL methods" do
def self.name
"B"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result.provides two_classes_one_dsl
@@ -1023,7 +977,9 @@ describe "Recipe DSL methods" do
def self.name
"A"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result
@@ -1060,7 +1016,9 @@ describe "Recipe DSL methods" do
def self.name
"Z"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result
@@ -1132,7 +1090,9 @@ describe "Recipe DSL methods" do
def self.name
"Blarghle"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result.resource_name two_classes_one_dsl
@@ -1170,6 +1130,7 @@ describe "Recipe DSL methods" do
def self.called_provides
@called_provides
end
+
def to_s
"MyResource"
end
@@ -1237,8 +1198,11 @@ describe "Recipe DSL methods" do
def self.name
"MyProvider"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
+
def self.called_provides
@called_provides
end
@@ -1256,7 +1220,7 @@ describe "Recipe DSL methods" do
context "with supports? returning true" do
before do
- provider_class.define_singleton_method(:supports?) { |resource,action| true }
+ provider_class.define_singleton_method(:supports?) { |resource, action| true }
end
it "my_resource runs the provider and does not emit a warning" do
@@ -1274,8 +1238,11 @@ describe "Recipe DSL methods" do
def self.name
"MyProvider2"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
+
def self.called_provides
@called_provides
end
@@ -1299,7 +1266,7 @@ describe "Recipe DSL methods" do
context "with supports? returning false" do
before do
- provider_class.define_singleton_method(:supports?) { |resource,action| false }
+ provider_class.define_singleton_method(:supports?) { |resource, action| false }
end
# TODO no warning? ick
@@ -1319,8 +1286,11 @@ describe "Recipe DSL methods" do
def self.name
"MyProvider2"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
+
def self.called_provides
@called_provides
end
@@ -1475,6 +1445,7 @@ describe "Recipe DSL methods" do
class Chef::Provider::LwResourceWithHwProviderTestCase < Chef::Provider
def load_current_resource
end
+
def action_create
new_resource.created_provider = self.class
end