summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-03-21 14:51:46 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2017-03-21 14:51:46 -0700
commitd23db7c88801551ef92af553764d0a38cc5d75f5 (patch)
tree64c147b77dd5c9edcacd94715c5da7061bacc1d1 /spec
parent3099264e4e44c4615622f1d69fc040a5d4d90500 (diff)
downloadchef-d23db7c88801551ef92af553764d0a38cc5d75f5.tar.gz
Chef-13: Simplify DSL creation
we did actually have tests around creating actions with spaces and hyphens in their names. we had fallback code for properties, but it was broken and threw a "private method define_resource called" and then it created a closure and didn't have the `name` in the binding so it called itself and blew up the stack. this change walks that back. it does prove that we still support UTF-8 in property names, actions and DSL names, which i'd argue is more than enough. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb18
-rw-r--r--spec/integration/recipes/resource_action_spec.rb6
-rw-r--r--spec/unit/property_spec.rb10
3 files changed, 31 insertions, 3 deletions
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index bc99dddaf3..32283393ce 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -1373,6 +1373,23 @@ describe "Recipe DSL methods" do
end
end
end
+
+ context "with UTF-8 provides" do
+ before(:context) do
+ class UTF8Thingy < BaseThingy
+ resource_name :Straße
+ provides :Straße
+ end
+ end
+
+ it "utf-8 dsl names work" do
+ recipe = converge do
+ Straße("blah") {}
+ end
+ expect(recipe.logged_warnings).to eq ""
+ expect(BaseThingy.created_resource).to eq(UTF8Thingy)
+ end
+ end
end
before(:all) { Namer.current_index = 0 }
@@ -1418,4 +1435,5 @@ describe "Recipe DSL methods" do
end
end
end
+
end
diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb
index f11696bae4..7a68164d41 100644
--- a/spec/integration/recipes/resource_action_spec.rb
+++ b/spec/integration/recipes/resource_action_spec.rb
@@ -357,7 +357,7 @@ module ResourceActionSpec
end
end
- context "With a resource with action a-b-c d" do
+ context "With a resource with a UTF-8 action" do
class WeirdActionJackson < Chef::Resource
use_automatic_resource_name
@@ -365,7 +365,7 @@ module ResourceActionSpec
attr_accessor :action_was
end
- action "a-b-c d" do
+ action :Straße do
WeirdActionJackson.action_was = action
end
end
@@ -374,7 +374,7 @@ module ResourceActionSpec
expect_recipe do
weird_action_jackson "hi"
end.to be_up_to_date
- expect(WeirdActionJackson.action_was).to eq :"a-b-c d"
+ expect(WeirdActionJackson.action_was).to eq :Straße
end
end
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index faeb774057..bd90891b63 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -108,6 +108,16 @@ describe "Chef::Resource.property" do
end
end
+ with_property ":Straße" do
+ it "properties with UTF-8 in their name work" do
+ expect(resource.Straße).to eql(nil)
+ expect(resource.Straße "foo").to eql("foo")
+ expect(resource.Straße).to eql("foo")
+ expect(resource.Straße = "bar").to eql("bar")
+ expect(resource.Straße).to eql("bar")
+ end
+ end
+
with_property ":x, name_property: true" do
context "and subclass" do
let(:subresource_class) do