diff options
Diffstat (limited to 'spec/unit/api_client_v1_spec.rb')
-rw-r--r-- | spec/unit/api_client_v1_spec.rb | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/spec/unit/api_client_v1_spec.rb b/spec/unit/api_client_v1_spec.rb index 6fb5ae40f2..920e522c6b 100644 --- a/spec/unit/api_client_v1_spec.rb +++ b/spec/unit/api_client_v1_spec.rb @@ -91,7 +91,6 @@ describe Chef::ApiClientV1 do expect { @client.public_key Hash.new }.to raise_error(ArgumentError) end - it "has a private key attribute" do @client.private_key("super private") expect(@client.private_key).to eq("super private") @@ -284,7 +283,6 @@ describe Chef::ApiClientV1 do it "includes the private key if present" do expect(@client.private_key).to eq("monkeypants") end - end describe "with correctly configured API credentials" do @@ -299,12 +297,10 @@ describe Chef::ApiClientV1 do end let :private_key_data do - File.open(Chef::Config[:client_key], "r") {|f| f.read.chomp } + File.open(Chef::Config[:client_key], "r") { |f| f.read.chomp } end - end - describe "when requesting a new key" do before do @http_client = double("Chef::ServerAPI mock") @@ -328,7 +324,7 @@ describe Chef::ApiClientV1 do describe "Versioned API Interactions" do let(:response_406) { OpenStruct.new(:code => "406") } let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) } - let(:payload) { + let(:payload) { { :name => "some_name", :validator => true, @@ -346,7 +342,6 @@ describe Chef::ApiClientV1 do end describe "create" do - # from spec/support/shared/unit/user_and_client_shared.rb it_should_behave_like "user or client create" do let(:object) { @client } @@ -365,12 +360,10 @@ describe Chef::ApiClientV1 do let(:rest_v1) { @client.chef_rest_v1 } end end - end # create describe "update" do context "when a valid client is defined" do - shared_examples_for "client updating" do it "updates the client" do expect(rest). to receive(:put).with("clients/some_name", payload).and_return(payload) @@ -378,7 +371,6 @@ describe Chef::ApiClientV1 do end context "when only the name field exists" do - before do # needed since there is no way to set to nil via code @client.instance_variable_set(:@validator, nil) @@ -391,19 +383,16 @@ describe Chef::ApiClientV1 do end it "updates the client with only the name" do - expect(rest). to receive(:put).with("clients/some_name", {:name => "some_name"}).and_return({:name => "some_name"}) + expect(rest). to receive(:put).with("clients/some_name", { :name => "some_name" }).and_return({ :name => "some_name" }) @client.update end end - end context "when API V1 is supported by the server" do - it_should_behave_like "client updating" do let(:rest) { @client.chef_rest_v1 } end - end # when API V1 is supported by the server context "when API V1 is not supported by the server" do @@ -418,7 +407,6 @@ describe Chef::ApiClientV1 do end # when no version is supported context "when API V0 is supported" do - before do allow(@client.chef_rest_v1).to receive(:put).and_raise(exception_406) allow(@client).to receive(:server_client_api_version_intersection).and_return([0]) @@ -427,9 +415,7 @@ describe Chef::ApiClientV1 do it_should_behave_like "client updating" do let(:rest) { @client.chef_rest_v0 } end - end - end # when API V1 is not supported by the server end # when a valid client is defined end # update @@ -439,7 +425,7 @@ describe Chef::ApiClientV1 do describe "reregister" do context "when server API V0 is valid on the Chef Server receiving the request" do it "creates a new object via the API" do - expect(@client.chef_rest_v0).to receive(:put).with("clients/#{@client.name}", payload.merge({:private_key => true})).and_return({}) + expect(@client.chef_rest_v0).to receive(:put).with("clients/#{@client.name}", payload.merge({ :private_key => true })).and_return({}) @client.reregister end end # when server API V0 is valid on the Chef Server receiving the request @@ -452,6 +438,5 @@ describe Chef::ApiClientV1 do end end # when server API V0 is not supported by the Chef Server end # reregister - end end |