summaryrefslogtreecommitdiff
path: root/spec/unit/policy_builder
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2015-12-02 12:19:33 +0000
committerThom May <thom@chef.io>2016-01-11 15:40:42 +0000
commitd99e306a41b1402209d320cb7119b12a3bbb962f (patch)
treef65940702826deb991e6198967d3e9e96cb2857a /spec/unit/policy_builder
parent1b71aeb423b009f6d1a44215c89e9976957b47e9 (diff)
downloadchef-tm/no_more_rest.tar.gz
Convert all uses of Chef::REST to Chef::ServerAPItm/no_more_rest
In the process, stop auto-expanding JSON in the HTTP client, and let individual classes control that themselves. Fixes #2737, Fixes #3518
Diffstat (limited to 'spec/unit/policy_builder')
-rw-r--r--spec/unit/policy_builder/expand_node_object_spec.rb8
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb6
2 files changed, 8 insertions, 6 deletions
diff --git a/spec/unit/policy_builder/expand_node_object_spec.rb b/spec/unit/policy_builder/expand_node_object_spec.rb
index 306d677108..944d4d3387 100644
--- a/spec/unit/policy_builder/expand_node_object_spec.rb
+++ b/spec/unit/policy_builder/expand_node_object_spec.rb
@@ -290,7 +290,7 @@ describe Chef::PolicyBuilder::ExpandNodeObject do
node
end
- let(:chef_http) { double("Chef::REST") }
+ let(:chef_http) { double("Chef::ServerAPI") }
let(:cookbook_resolve_url) { "environments/#{node.chef_environment}/cookbook_versions" }
let(:cookbook_resolve_post_data) { {:run_list=>["first::default", "second::default"]} }
@@ -298,7 +298,8 @@ describe Chef::PolicyBuilder::ExpandNodeObject do
# cookbook_hash is just a hash, but since we're passing it between mock
# objects, we get a little better test strictness by using a double (which
# will have object equality rather than semantic equality #== semantics).
- let(:cookbook_hash) { double("cookbook hash", :each => nil) }
+ let(:cookbook_hash) { double("cookbook hash") }
+ let(:expanded_cookbook_hash) { double("expanded cookbook hash", :each => nil) }
let(:cookbook_synchronizer) { double("CookbookSynchronizer") }
@@ -310,8 +311,9 @@ describe Chef::PolicyBuilder::ExpandNodeObject do
run_list_expansion = policy_builder.run_list_expansion
+ expect(cookbook_hash).to receive(:inject).and_return(expanded_cookbook_hash)
expect(chef_http).to receive(:post).with(cookbook_resolve_url, cookbook_resolve_post_data).and_return(cookbook_hash)
- expect(Chef::CookbookSynchronizer).to receive(:new).with(cookbook_hash, events).and_return(cookbook_synchronizer)
+ expect(Chef::CookbookSynchronizer).to receive(:new).with(expanded_cookbook_hash, events).and_return(cookbook_synchronizer)
expect(cookbook_synchronizer).to receive(:sync_cookbooks)
expect_any_instance_of(Chef::RunContext).to receive(:load).with(run_list_expansion)
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index ed893260c2..3dfa8d9802 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -98,10 +98,10 @@ describe Chef::PolicyBuilder::Policyfile do
let(:err_namespace) { Chef::PolicyBuilder::Policyfile }
it "configures a Chef HTTP API client" do
- http = double("Chef::REST")
+ http = double("Chef::ServerAPI")
server_url = "https://api.opscode.com/organizations/example"
Chef::Config[:chef_server_url] = server_url
- expect(Chef::REST).to receive(:new).with(server_url).and_return(http)
+ expect(Chef::ServerAPI).to receive(:new).with(server_url).and_return(http)
expect(policy_builder.http_api).to eq(http)
end
@@ -151,7 +151,7 @@ describe Chef::PolicyBuilder::Policyfile do
describe "loading policy data" do
- let(:http_api) { double("Chef::REST") }
+ let(:http_api) { double("Chef::ServerAPI") }
let(:configured_environment) { nil }