diff options
author | tylercloke <tylercloke@gmail.com> | 2015-05-27 14:32:24 -0700 |
---|---|---|
committer | tylercloke <tylercloke@gmail.com> | 2015-06-05 10:38:48 -0700 |
commit | 9b9d376f2e86cd2738c2c2928f77bf48f1dd20ee (patch) | |
tree | 226227e7e32f421a0dde0f1ad2046059eff449c3 /spec/unit/formatters | |
parent | 20f7e1c78c55d2a16d5033bc2bbe5904d225adb0 (diff) | |
download | chef-9b9d376f2e86cd2738c2c2928f77bf48f1dd20ee.tar.gz |
Added versioned Chef Object API support code and repaired Chef::User.create.
Also added Chef::User.create V1 API support. Chef::User.create will attempt to use V1 of the server API, and if it fails, it will fall back to V0.
Diffstat (limited to 'spec/unit/formatters')
-rw-r--r-- | spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb b/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb index 4b3b8bff44..b8c2de2b8b 100644 --- a/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +++ b/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb @@ -29,19 +29,21 @@ describe Chef::Formatters::APIErrorFormatting do context "when describe_406_error is called" do - context "when response.body['error'] == 'invalid-x-ops-server-api-version'" do + context "when response['x-ops-server-api-version'] exists" do let(:min_version) { "2" } let(:max_version) { "5" } + let(:request_version) { "30" } let(:return_hash) { { - "error" => "invalid-x-ops-server-api-version", "min_version" => min_version, - "max_version" => max_version + "max_version" => max_version, + "request_version" => request_version } } before do - allow(Chef::JSONCompat).to receive(:from_json).and_return(return_hash) + # mock out the header + allow(response).to receive(:[]).with('x-ops-server-api-version').and_return(Chef::JSONCompat.to_json(return_hash)) end it "prints an error about client and server API version incompatibility with a min API version" do @@ -53,17 +55,17 @@ describe Chef::Formatters::APIErrorFormatting do expect(error_description).to receive(:section).with("Incompatible server API version:",/a max API version of #{max_version}/) class_instance.describe_406_error(error_description, response) end + + it "prints an error describing the request API version" do + expect(error_description).to receive(:section).with("Incompatible server API version:",/a request with an API version of #{request_version}/) + class_instance.describe_406_error(error_description, response) + end end context "when response.body['error'] != 'invalid-x-ops-server-api-version'" do - let(:return_hash) { - { - "error" => "some-other-error" - } - } before do - allow(Chef::JSONCompat).to receive(:from_json).and_return(return_hash) + allow(response).to receive(:[]).with('x-ops-server-api-version').and_return(nil) end it "forwards the error_description to describe_http_error" do |