diff options
author | sdelano <stephen@opscode.com> | 2017-04-06 10:14:03 -0700 |
---|---|---|
committer | sdelano <stephen@opscode.com> | 2017-04-06 10:14:03 -0700 |
commit | 9ffe51037b800efa5bd19ce5eab904b2fb475168 (patch) | |
tree | 51ea376b64a3135571e34e0d4fd2e17634937dd6 | |
parent | adb0a55cb63f394ed23450e41f8a93cd017d225a (diff) | |
download | chef-9ffe51037b800efa5bd19ce5eab904b2fb475168.tar.gz |
chefstyle fixes
Signed-off-by: Stephen Delano <stephen@chef.io>
-rw-r--r-- | lib/chef/client.rb | 51 | ||||
-rw-r--r-- | spec/unit/client_spec.rb | 8 |
2 files changed, 28 insertions, 31 deletions
diff --git a/lib/chef/client.rb b/lib/chef/client.rb index 8dea2afecf..06325e0a23 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -531,34 +531,31 @@ class Chef # the existing rest client in as a parameter # def load_required_recipe(rest, run_context) - begin - required_recipe_contents = rest.get("required_recipe") - Chef::FileCache.store("required_recipe", required_recipe_contents) - required_recipe_file = Chef::FileCache.load("required_recipe", false) - - # TODO: add integration tests with resource reporting turned on - # (presumably requires changes to chef-zero) - # - # Chef::Recipe.new takes a cookbook name and a recipe name along - # with the run context. These names are eventually used in the - # resource reporter, and if the cookbook name cannot be found in the - # cookbook collection then we will fail with an exception. Cases where - # we currently also fail: - # - specific recipes - # - chef-apply would fail if resource reporting was enabled - # - recipe = Chef::Recipe.new(nil, nil, run_context) - recipe.from_file(required_recipe_file) - run_context - rescue Net::HTTPServerException => e - case e.response - when Net::HTTPNotFound - Chef::Log.info("Required Recipe not found") - else - raise - end - end + required_recipe_contents = rest.get("required_recipe") + Chef::FileCache.store("required_recipe", required_recipe_contents) + required_recipe_file = Chef::FileCache.load("required_recipe", false) + # TODO: add integration tests with resource reporting turned on + # (presumably requires changes to chef-zero) + # + # Chef::Recipe.new takes a cookbook name and a recipe name along + # with the run context. These names are eventually used in the + # resource reporter, and if the cookbook name cannot be found in the + # cookbook collection then we will fail with an exception. Cases where + # we currently also fail: + # - specific recipes + # - chef-apply would fail if resource reporting was enabled + # + recipe = Chef::Recipe.new(nil, nil, run_context) + recipe.from_file(required_recipe_file) + run_context + rescue Net::HTTPServerException => e + case e.response + when Net::HTTPNotFound + Chef::Log.info("Required Recipe not found") + else + raise + end end # diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index 528dbd4b4e..064876a82f 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -398,11 +398,11 @@ describe Chef::Client do let(:rest) { double("Chef::ServerAPI (required recipe)") } let(:run_context) { double("Chef::RunContext") } let(:recipe) { double("Chef::Recipe (required recipe)") } - let(:required_recipe) { + let(:required_recipe) do <<EOM fake_recipe_variable = "for reals" EOM - } + end context "when required_recipe is configured" do @@ -417,11 +417,11 @@ EOM end context "when the required_recipe has bad contents" do - let(:required_recipe) { + let(:required_recipe) do <<EOM this is not a recipe EOM - } + end it "should not raise an error" do expect { client.load_required_recipe(rest, run_context) }.not_to raise_error() end |