diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-30 12:24:56 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-30 12:24:56 -0700 |
commit | de209e6ee12939f641ec0ed002c2d3506abaafe7 (patch) | |
tree | 0a6b37f0519a71444250c5ffd84d3df89649228d /spec | |
parent | 5584126a725ab72c24ea610328f56a905986295b (diff) | |
download | chef-de209e6ee12939f641ec0ed002c2d3506abaafe7.tar.gz |
make nameless properties opt-in
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/integration/recipes/recipe_dsl_spec.rb | 27 | ||||
-rw-r--r-- | spec/unit/dsl/resources_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/recipe_spec.rb | 5 |
3 files changed, 23 insertions, 11 deletions
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb index 14cee0e1fd..f7a0e8b6e8 100644 --- a/spec/integration/recipes/recipe_dsl_spec.rb +++ b/spec/integration/recipes/recipe_dsl_spec.rb @@ -59,13 +59,30 @@ describe "Recipe DSL methods" do expect(BaseThingy.created_resource).to eq BaseThingy end - it "does not errors when you call base_thingy do ... end in a recipe" do - recipe = converge do + it "errors when you call base_thingy do ... end in a recipe" do + expect_converge do base_thingy { ; } + end.to raise_error(Chef::Exceptions::ValidationFailed) + end + + context "nameless resources" do + before(:context) do + class NamelessThingy < BaseThingy + resource_name :nameless_thingy + provides :nameless_thingy + + property :name, String, default: "" + end + end + + it "does not error when not given a name" do + recipe = converge do + nameless_thingy {} + end + expect(recipe.logged_warnings).to eq "" + expect(BaseThingy.created_name).to eq "" + expect(BaseThingy.created_resource).to eq NamelessThingy end - expect(recipe.logged_warnings).to eq "" - expect(BaseThingy.created_name).to eq "" - expect(BaseThingy.created_resource).to eq BaseThingy end context "Deprecated automatic resource DSL" do diff --git a/spec/unit/dsl/resources_spec.rb b/spec/unit/dsl/resources_spec.rb index 5354505df8..dc05f8bcf4 100644 --- a/spec/unit/dsl/resources_spec.rb +++ b/spec/unit/dsl/resources_spec.rb @@ -80,6 +80,6 @@ describe Chef::DSL::Resources do test_resource {} end end - it { is_expected.to eq [[:test_resource, ""]] } + it { is_expected.to eq [[:test_resource, nil]] } end end diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb index c60f470a77..7a538b721b 100644 --- a/spec/unit/recipe_spec.rb +++ b/spec/unit/recipe_spec.rb @@ -74,11 +74,6 @@ describe Chef::Recipe do expect { recipe.not_home("not_home_resource") }.to raise_error(NameError) end - it "does not require a name argument and looks up with empty brackets" do - recipe.zen_master - expect(run_context.resource_collection.lookup("zen_master[]").name).to eql("") - end - it "should allow regular errors (not NameErrors) to pass unchanged" do expect do recipe.cat("felix") { raise ArgumentError, "You Suck" } |