summaryrefslogtreecommitdiff
path: root/spec/unit/policy_builder
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2017-03-21 10:31:40 +0000
committerThom May <thom@chef.io>2017-04-04 07:18:09 +0100
commit8f62f18a24e3213ef4b2f13a5abf0135bf6c2429 (patch)
tree7e3073c1b9a7aeb1fd54b08a191ad3bfcf0674f0 /spec/unit/policy_builder
parente3b9e67a880bcd658517f90a6add837c0e026798 (diff)
downloadchef-8f62f18a24e3213ef4b2f13a5abf0135bf6c2429.tar.gz
RFC 67: Remove cookbook segments
This implements RFC 67, which removes cookbook segments, and moves to a single list of all the files contained in a cookbook. This allows us to move forward with better audit modes and also proper shipping of ohai plugins. Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'spec/unit/policy_builder')
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index 307bd45c18..c9086c2f63 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -100,8 +100,8 @@ describe Chef::PolicyBuilder::Policyfile do
http = double("Chef::ServerAPI")
server_url = "https://api.opscode.com/organizations/example"
Chef::Config[:chef_server_url] = server_url
- expect(Chef::ServerAPI).to receive(:new).with(server_url).and_return(http)
- expect(policy_builder.http_api).to eq(http)
+ expect(Chef::ServerAPI).to receive(:new).with(server_url, version_class: Chef::CookbookManifestVersions).and_return(http)
+ expect(policy_builder.api_service).to eq(http)
end
describe "reporting unsupported features" do
@@ -150,7 +150,7 @@ describe Chef::PolicyBuilder::Policyfile do
describe "loading policy data" do
- let(:http_api) { double("Chef::ServerAPI") }
+ let(:api_service) { double("Chef::ServerAPI") }
let(:configured_environment) { nil }
@@ -172,7 +172,7 @@ describe Chef::PolicyBuilder::Policyfile do
before do
Chef::Config[:policy_document_native_api] = false
Chef::Config[:deployment_group] = "example-policy-stage"
- allow(policy_builder).to receive(:http_api).and_return(http_api)
+ allow(policy_builder).to receive(:api_service).and_return(api_service)
end
describe "when using compatibility mode (policy_document_native_api == false)" do
@@ -185,7 +185,7 @@ describe Chef::PolicyBuilder::Policyfile do
let(:error404) { Net::HTTPServerException.new("404 message", :body) }
before do
- expect(http_api).to receive(:get).
+ expect(api_service).to receive(:get).
with("data/policyfiles/example-policy-stage").
and_raise(error404)
end
@@ -212,7 +212,7 @@ describe Chef::PolicyBuilder::Policyfile do
let(:policy_relative_url) { "data/policyfiles/example-policy-stage" }
before do
- expect(http_api).to receive(:get).with(policy_relative_url).and_return(parsed_policyfile_json)
+ expect(api_service).to receive(:get).with(policy_relative_url).and_return(parsed_policyfile_json)
end
it "fetches the policy file from a data bag item" do
@@ -253,7 +253,7 @@ describe Chef::PolicyBuilder::Policyfile do
let(:policy_relative_url) { "policy_groups/policy-stage/policies/example" }
before do
- expect(http_api).to receive(:get).with(policy_relative_url).and_return(parsed_policyfile_json)
+ expect(api_service).to receive(:get).with(policy_relative_url).and_return(parsed_policyfile_json)
end
it "fetches the policy file from a data bag item" do
@@ -617,7 +617,7 @@ describe Chef::PolicyBuilder::Policyfile do
policy_builder.finish_load_node(node)
policy_builder.build_node
- expect(http_api).to receive(:get).with(cookbook1_url).
+ expect(api_service).to receive(:get).with(cookbook1_url).
and_raise(error404)
end
@@ -687,9 +687,9 @@ describe Chef::PolicyBuilder::Policyfile do
context "when the cookbooks exist on the server" do
before do
- expect(http_api).to receive(:get).with(cookbook1_url).
+ expect(api_service).to receive(:get).with(cookbook1_url).
and_return(example1_cookbook_data)
- expect(http_api).to receive(:get).with(cookbook2_url).
+ expect(api_service).to receive(:get).with(cookbook2_url).
and_return(example2_cookbook_data)
expect(Chef::CookbookVersion).to receive(:from_cb_artifact_data).with(example1_cookbook_data).
@@ -720,9 +720,9 @@ describe Chef::PolicyBuilder::Policyfile do
context "when the cookbooks exist on the server" do
before do
- expect(http_api).to receive(:get).with(cookbook1_url).
+ expect(api_service).to receive(:get).with(cookbook1_url).
and_return(example1_cookbook_data)
- expect(http_api).to receive(:get).with(cookbook2_url).
+ expect(api_service).to receive(:get).with(cookbook2_url).
and_return(example2_cookbook_data)
expect(Chef::CookbookVersion).to receive(:from_cb_artifact_data).with(example1_cookbook_data).