diff options
author | danielsdeleo <dan@getchef.com> | 2015-01-22 19:08:29 -0800 |
---|---|---|
committer | danielsdeleo <dan@getchef.com> | 2015-01-27 12:46:14 -0800 |
commit | 2f817d8d00135abadc9a279e20a448f9ffe91a1c (patch) | |
tree | 7922a9cd1916b6f4dc2ddb3016d5758408d5c088 /spec/unit/policy_builder | |
parent | 4fafa081d8418e40b29c8b6fae92ff850a8191f1 (diff) | |
download | chef-2f817d8d00135abadc9a279e20a448f9ffe91a1c.tar.gz |
Add policyfile native support to policy builder
Diffstat (limited to 'spec/unit/policy_builder')
-rw-r--r-- | spec/unit/policy_builder/policyfile_spec.rb | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb index 5e2844201d..92cdd7f57e 100644 --- a/spec/unit/policy_builder/policyfile_spec.rb +++ b/spec/unit/policy_builder/policyfile_spec.rb @@ -211,9 +211,54 @@ describe Chef::PolicyBuilder::Policyfile do end end + context "and policy_document_native_api is configured" do + + before do + Chef::Config[:policy_document_native_api] = true + Chef::Config[:policy_group] = "policy-stage" + Chef::Config[:policy_name] = "example" + end + + context "and policy_name or policy_group are not configured" do + + it "raises a Configuration error for policy_group" do + Chef::Config[:policy_group] = nil + expect { policy_builder.policy }.to raise_error(err_namespace::ConfigurationError) + end + + it "raises a Configuration error for policy_name" do + Chef::Config[:policy_name] = nil + expect { policy_builder.policy }.to raise_error(err_namespace::ConfigurationError) + end + + end + + context "and policy_name and policy_group are configured" do + + let(:policy_relative_url) { "policies/policy-stage/example" } + + before do + expect(http_api).to receive(:get).with(policy_relative_url).and_return(parsed_policyfile_json) + end + + it "fetches the policy file from a data bag item" do + expect(policy_builder.policy).to eq(parsed_policyfile_json) + end + + it "extracts the run_list from the policyfile" do + expect(policy_builder.run_list).to eq(policyfile_run_list) + end + end + + end + + context "and a deployment_group is configured" do + + let(:policy_relative_url) { "data/policyfiles/example-policy-stage" } + before do - expect(http_api).to receive(:get).with("data/policyfiles/example-policy-stage").and_return(parsed_policyfile_json) + expect(http_api).to receive(:get).with(policy_relative_url).and_return(parsed_policyfile_json) end it "fetches the policy file from a data bag item" do |