diff options
-rw-r--r-- | CHANGELOG.md | 10 | ||||
-rw-r--r-- | Gemfile.lock | 34 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | chef-bin/lib/chef-bin/version.rb | 2 | ||||
-rw-r--r-- | chef-config/lib/chef-config/version.rb | 2 | ||||
-rw-r--r-- | chef-utils/lib/chef-utils/version.rb | 2 | ||||
-rw-r--r-- | knife/lib/chef/knife/user_create.rb | 8 | ||||
-rw-r--r-- | knife/lib/chef/knife/version.rb | 2 | ||||
-rw-r--r-- | knife/spec/unit/knife/user_create_spec.rb | 42 | ||||
-rw-r--r-- | lib/chef/provider/http_request.rb | 20 | ||||
-rw-r--r-- | lib/chef/version.rb | 2 | ||||
-rw-r--r-- | omnibus/Gemfile.lock | 14 | ||||
-rw-r--r-- | spec/unit/provider/http_request_spec.rb | 132 | ||||
-rw-r--r-- | tasks/rspec.rb | 2 |
14 files changed, 148 insertions, 126 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e7e19fd6d..75ed960346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,21 @@ <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ --> This changelog lists individual merged pull requests to Chef Infra Client and geared towards developers. For a list of significant changes per release see the [Chef Infra Client Release Notes](https://docs.chef.io/release_notes_client/). -<!-- latest_release 18.0.65 --> -## [v18.0.65](https://github.com/chef/chef/tree/v18.0.65) (2022-03-02) +<!-- latest_release 18.0.69 --> +## [v18.0.69](https://github.com/chef/chef/tree/v18.0.69) (2022-03-15) #### Merged Pull Requests -- turn off caching for adhoc pipelines [#12661](https://github.com/chef/chef/pull/12661) ([lamont-granquist](https://github.com/lamont-granquist)) +- Fix PEM file generation when user is created [#12619](https://github.com/chef/chef/pull/12619) ([sanjain-progress](https://github.com/sanjain-progress)) <!-- latest_release --> <!-- release_rollup since=17.9.26 --> ### Changes not yet released to stable #### Merged Pull Requests +- Fix PEM file generation when user is created [#12619](https://github.com/chef/chef/pull/12619) ([sanjain-progress](https://github.com/sanjain-progress)) <!-- 18.0.69 --> +- Bump omnibus-software from `f64a223` to `5947560` in /omnibus [#12670](https://github.com/chef/chef/pull/12670) ([dependabot[bot]](https://github.com/dependabot[bot])) <!-- 18.0.68 --> +- Modernize the http_request resource code and specs [#12682](https://github.com/chef/chef/pull/12682) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 18.0.67 --> +- Updated Rspec to add verbose logging [#12683](https://github.com/chef/chef/pull/12683) ([johnmccrae](https://github.com/johnmccrae)) <!-- 18.0.66 --> - turn off caching for adhoc pipelines [#12661](https://github.com/chef/chef/pull/12661) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 18.0.65 --> - Add OMNITRUCK_URL dist constant [#12654](https://github.com/chef/chef/pull/12654) ([ramereth](https://github.com/ramereth)) <!-- 18.0.64 --> - Update to libffi 3.4.2 [#12658](https://github.com/chef/chef/pull/12658) ([tas50](https://github.com/tas50)) <!-- 18.0.63 --> diff --git a/Gemfile.lock b/Gemfile.lock index d780bda12e..92a1c833d5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -35,12 +35,12 @@ GIT PATH remote: . specs: - chef (18.0.65) + chef (18.0.69) addressable aws-sdk-s3 (~> 1.91) aws-sdk-secretsmanager (~> 1.46) - chef-config (= 18.0.65) - chef-utils (= 18.0.65) + chef-config (= 18.0.69) + chef-utils (= 18.0.69) chef-vault chef-zero (>= 14.0.11) corefoundation (~> 0.3.4) @@ -68,13 +68,13 @@ PATH train-winrm (>= 0.2.5) uuidtools (>= 2.1.5, < 3.0) vault (~> 0.16) - chef (18.0.65-universal-mingw32) + chef (18.0.69-universal-mingw32) addressable aws-sdk-s3 (~> 1.91) aws-sdk-secretsmanager (~> 1.46) - chef-config (= 18.0.65) + chef-config (= 18.0.69) chef-powershell (~> 1.0.12) - chef-utils (= 18.0.65) + chef-utils (= 18.0.69) chef-vault chef-zero (>= 14.0.11) corefoundation (~> 0.3.4) @@ -117,15 +117,15 @@ PATH PATH remote: chef-bin specs: - chef-bin (18.0.65) - chef (= 18.0.65) + chef-bin (18.0.69) + chef (= 18.0.69) PATH remote: chef-config specs: - chef-config (18.0.65) + chef-config (18.0.69) addressable - chef-utils (= 18.0.65) + chef-utils (= 18.0.69) fuzzyurl mixlib-config (>= 2.2.12, < 4.0) mixlib-shellout (>= 2.0, < 4.0) @@ -134,7 +134,7 @@ PATH PATH remote: chef-utils specs: - chef-utils (18.0.65) + chef-utils (18.0.69) concurrent-ruby GEM @@ -147,8 +147,8 @@ GEM mixlib-shellout (>= 2.0, < 4.0) ast (2.4.2) aws-eventstream (1.2.0) - aws-partitions (1.566.0) - aws-sdk-core (3.129.1) + aws-partitions (1.567.0) + aws-sdk-core (3.130.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.525.0) aws-sigv4 (~> 1.1) @@ -160,7 +160,7 @@ GEM aws-sdk-core (~> 3, >= 3.127.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) - aws-sdk-secretsmanager (1.58.0) + aws-sdk-secretsmanager (1.59.0) aws-sdk-core (~> 3, >= 3.127.0) aws-sigv4 (~> 1.1) aws-sigv4 (1.4.0) @@ -434,9 +434,9 @@ GEM tty-screen (~> 0.8) unf (0.1.4) unf_ext - unf_ext (0.0.8) - unf_ext (0.0.8-x64-mingw32) - unf_ext (0.0.8-x86-mingw32) + unf_ext (0.0.8.1) + unf_ext (0.0.8.1-x64-mingw32) + unf_ext (0.0.8.1-x86-mingw32) unicode-display_width (2.1.0) unicode_utils (1.4.0) uuidtools (2.2.0) @@ -1 +1 @@ -18.0.65
\ No newline at end of file +18.0.69
\ No newline at end of file diff --git a/chef-bin/lib/chef-bin/version.rb b/chef-bin/lib/chef-bin/version.rb index 1ec4f36b60..4b439eb31f 100644 --- a/chef-bin/lib/chef-bin/version.rb +++ b/chef-bin/lib/chef-bin/version.rb @@ -21,7 +21,7 @@ module ChefBin CHEFBIN_ROOT = File.expand_path("..", __dir__) - VERSION = "18.0.65".freeze + VERSION = "18.0.69".freeze end # diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index 532274ba55..0aa6ed8dcf 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -15,5 +15,5 @@ module ChefConfig CHEFCONFIG_ROOT = File.expand_path("..", __dir__) - VERSION = "18.0.65".freeze + VERSION = "18.0.69".freeze end diff --git a/chef-utils/lib/chef-utils/version.rb b/chef-utils/lib/chef-utils/version.rb index b9c2a3ab87..d2d23ec45a 100644 --- a/chef-utils/lib/chef-utils/version.rb +++ b/chef-utils/lib/chef-utils/version.rb @@ -16,5 +16,5 @@ module ChefUtils CHEFUTILS_ROOT = File.expand_path("..", __dir__) - VERSION = "18.0.65" + VERSION = "18.0.69" end diff --git a/knife/lib/chef/knife/user_create.rb b/knife/lib/chef/knife/user_create.rb index 009f193d46..158e8d11cd 100644 --- a/knife/lib/chef/knife/user_create.rb +++ b/knife/lib/chef/knife/user_create.rb @@ -128,6 +128,7 @@ class Chef display_name: "#{user.first_name} #{user.last_name}", email: user.email, password: password, + create_key: user.create_key, } else user_hash = { @@ -137,6 +138,7 @@ class Chef display_name: user.display_name, email: user.email, password: password, + create_key: user.create_key, } end @@ -159,13 +161,13 @@ class Chef end ui.info("Created #{user.username}") - if final_user["private_key"] + if final_user["chef_key"] && final_user["chef_key"]["private_key"] if config[:file] File.open(config[:file], "w") do |f| - f.print(final_user["private_key"]) + f.print(final_user["chef_key"]["private_key"]) end else - ui.msg final_user["private_key"] + ui.msg final_user["chef_key"]["private_key"] end end end diff --git a/knife/lib/chef/knife/version.rb b/knife/lib/chef/knife/version.rb index 6c44bcdabf..861dc26de5 100644 --- a/knife/lib/chef/knife/version.rb +++ b/knife/lib/chef/knife/version.rb @@ -17,7 +17,7 @@ class Chef class Knife KNIFE_ROOT = File.expand_path("../..", __dir__) - VERSION = "18.0.65".freeze + VERSION = "18.0.69".freeze end end diff --git a/knife/spec/unit/knife/user_create_spec.rb b/knife/spec/unit/knife/user_create_spec.rb index 1257d92ee9..32a3448205 100644 --- a/knife/spec/unit/knife/user_create_spec.rb +++ b/knife/spec/unit/knife/user_create_spec.rb @@ -16,7 +16,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - require "knife_spec_helper" Chef::Knife::UserCreate.load_deps @@ -80,7 +79,7 @@ describe Chef::Knife::UserCreate do before :each do @user = double("Chef::User") @key = "You don't come into cooking to get rich - Ramsay" - allow(@user).to receive(:[]).with("private_key").and_return(@key) + allow(@user).to receive(:[]).with("chef_key").and_return(@key) knife.config[:passwordprompt] = true knife.name_args = name_args end @@ -97,7 +96,7 @@ describe Chef::Knife::UserCreate do before do @user = double("Chef::User") @key = "You don't come into cooking to get rich - Ramsay" - allow(@user).to receive(:[]).with("private_key").and_return(@key) + allow(@user).to receive(:[]).with("chef_key").and_return(@key) knife.name_args = %w{some_user some_display_name some_first_name some_last_name some_email some_password} end @@ -177,17 +176,39 @@ describe Chef::Knife::UserCreate do describe "with user_name, first_name, last_name, email and password" do let(:name_args) { %w{some_user some_display_name some_first_name some_last_name test@email.com some_password} } + before :each do + @user = double("Chef::User") + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) + expect(root_rest).to receive(:post).and_return(@user) + @key = IO.read(File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem")) + allow(@user).to receive(:[]).with("chef_key").and_return(nil) + knife.name_args = name_args + end + + it "creates an user without private key" do + expect(knife.ui).to_not receive(:msg).with(@key) + knife.run + end + end + describe "with user_name, first_name, last_name, email and password" do + let(:name_args) { %w{some_user some_display_name some_first_name some_last_name test@email.com some_password} } before :each do @user = double("Chef::User") expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) - @key = "You don't come into cooking to get rich - Ramsay" - allow(@user).to receive(:[]).with("private_key").and_return(@key) + @username = "Created #{name_args.first}" + @key = IO.read(File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem")) + allow(@user).to receive(:[]).with("chef_key").and_return("private_key" => @key) knife.name_args = name_args end it "creates an user" do + expect(knife.ui).to receive(:info).with(@username) + knife.run + end + + it "creates an user private key" do expect(knife.ui).to receive(:msg).with(@key) knife.run end @@ -204,7 +225,6 @@ describe Chef::Knife::UserCreate do } it "creates an user, associates a user, and adds it to the admins group" do - expect(root_rest).to receive(:post).with("organizations/ramsay/association_requests", request_body).and_return(@user) expect(root_rest).to receive(:put).with("users/some_user/association_requests/1", { response: "accept" }) knife.run @@ -219,14 +239,20 @@ describe Chef::Knife::UserCreate do @user = double("Chef::User") expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) - @key = "You don't come into cooking to get rich - Ramsay" - allow(@user).to receive(:[]).with("private_key").and_return(@key) + @username = "Created #{name_args.first}" + @key = IO.read(File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem")) + allow(@user).to receive(:[]).with("chef_key").and_return("private_key" => @key) knife.name_args = name_args knife.config[:email] = "test@email.com" knife.config[:password] = "some_password" end it "creates an user" do + expect(knife.ui).to receive(:info).with(@username) + knife.run + end + + it "creates an user private key" do expect(knife.ui).to receive(:msg).with(@key) knife.run end diff --git a/lib/chef/provider/http_request.rb b/lib/chef/provider/http_request.rb index 8e7a7f1fc9..0b25c728cf 100644 --- a/lib/chef/provider/http_request.rb +++ b/lib/chef/provider/http_request.rb @@ -25,18 +25,20 @@ class Chef provides :http_request - attr_accessor :http + attr_writer :http - def load_current_resource - @http = Chef::HTTP::Simple.new(new_resource.url) + def http + @http ||= Chef::HTTP::Simple.new(new_resource.url) end + def load_current_resource; end + # Send a HEAD request to new_resource.url action :head do message = check_message(new_resource.message) # CHEF-4762: we expect a nil return value from Chef::HTTP for a "200 Success" response # and false for a "304 Not Modified" response - modified = @http.head( + modified = http.head( (new_resource.url).to_s, new_resource.headers ) @@ -53,7 +55,7 @@ class Chef converge_by("#{new_resource} GET to #{new_resource.url}") do message = check_message(new_resource.message) - body = @http.get( + body = http.get( (new_resource.url).to_s, new_resource.headers ) @@ -66,7 +68,7 @@ class Chef action :patch do converge_by("#{new_resource} PATCH to #{new_resource.url}") do message = check_message(new_resource.message) - body = @http.patch( + body = http.patch( (new_resource.url).to_s, message, new_resource.headers @@ -80,7 +82,7 @@ class Chef action :put do converge_by("#{new_resource} PUT to #{new_resource.url}") do message = check_message(new_resource.message) - body = @http.put( + body = http.put( (new_resource.url).to_s, message, new_resource.headers @@ -94,7 +96,7 @@ class Chef action :post do converge_by("#{new_resource} POST to #{new_resource.url}") do message = check_message(new_resource.message) - body = @http.post( + body = http.post( (new_resource.url).to_s, message, new_resource.headers @@ -107,7 +109,7 @@ class Chef # Send a DELETE request to new_resource.url action :delete do converge_by("#{new_resource} DELETE to #{new_resource.url}") do - body = @http.delete( + body = http.delete( (new_resource.url).to_s, new_resource.headers ) diff --git a/lib/chef/version.rb b/lib/chef/version.rb index 3d2e499340..3ae1f98a4b 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -23,7 +23,7 @@ require_relative "version_string" class Chef CHEF_ROOT = File.expand_path("..", __dir__) - VERSION = Chef::VersionString.new("18.0.65") + VERSION = Chef::VersionString.new("18.0.69") end # diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock index 892cc35de0..27136e3792 100644 --- a/omnibus/Gemfile.lock +++ b/omnibus/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/chef/omnibus-software.git - revision: f64a223f8a90a8fe74154e155564ca9211de0c38 + revision: 5947560ea75ff76243d39243ede62fa45f979895 branch: main specs: omnibus-software (4.0.0) @@ -33,17 +33,17 @@ GEM artifactory (3.0.15) awesome_print (1.9.2) aws-eventstream (1.2.0) - aws-partitions (1.558.0) - aws-sdk-core (3.126.2) + aws-partitions (1.563.0) + aws-sdk-core (3.128.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.525.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.54.0) - aws-sdk-core (~> 3, >= 3.126.0) + aws-sdk-kms (1.55.0) + aws-sdk-core (~> 3, >= 3.127.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.112.0) - aws-sdk-core (~> 3, >= 3.126.0) + aws-sdk-s3 (1.113.0) + aws-sdk-core (~> 3, >= 3.127.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) aws-sdk-secretsmanager (1.57.0) diff --git a/spec/unit/provider/http_request_spec.rb b/spec/unit/provider/http_request_spec.rb index b30ed2dd30..595b1f4295 100644 --- a/spec/unit/provider/http_request_spec.rb +++ b/spec/unit/provider/http_request_spec.rb @@ -19,87 +19,75 @@ require "spec_helper" describe Chef::Provider::HttpRequest do - before(:each) do - @node = Chef::Node.new - @events = Chef::EventDispatch::Dispatcher.new - @run_context = Chef::RunContext.new(@node, {}, @events) - - @new_resource = Chef::Resource::HttpRequest.new("adam") - @new_resource.name "adam" - @new_resource.url "http://www.opscode.com/" - @new_resource.message "is cool" - - @provider = Chef::Provider::HttpRequest.new(@new_resource, @run_context) - end - - describe "load_current_resource" do - - it "should set up a Chef::ServerAPI client, with no authentication" do - expect(Chef::HTTP::Simple).to receive(:new).with(@new_resource.url) - @provider.load_current_resource + let(:node) { Chef::Node.new } + let(:events) { Chef::EventDispatch::Dispatcher.new } + let(:run_context) { Chef::RunContext.new(node, {}, events) } + let(:new_resource) do + Chef::Resource::HttpRequest.new("adam").tap do |new_resource| + new_resource.name "adam" + new_resource.url "http://www.opscode.com/" + new_resource.message "is cool" end end + let(:provider) { Chef::Provider::HttpRequest.new(new_resource, run_context) } + describe "when making REST calls" do - before(:each) do - # run_action(x) forces load_current_resource to run; - # that would overwrite our supplied mock Chef::Rest # object - allow(@provider).to receive(:load_current_resource).and_return(true) - @http = double("Chef::ServerAPI") - @provider.http = @http + let(:http) do + provider.http = double("Chef::ServerAPI") end describe "action_get" do it "should inflate a message block at runtime" do - @new_resource.message { "return" } - expect(@http).to receive(:get).with("http://www.opscode.com/", {}) - @provider.run_action(:get) - expect(@new_resource).to be_updated + new_resource.message { "return" } + expect(http).to receive(:get).with("http://www.opscode.com/", {}) + provider.run_action(:get) + expect(new_resource).to be_updated end it "should run a GET request" do - expect(@http).to receive(:get).with("http://www.opscode.com/", {}) - @provider.run_action(:get) - expect(@new_resource).to be_updated + expect(http).to receive(:get).with("http://www.opscode.com/", {}) + provider.run_action(:get) + expect(new_resource).to be_updated end end describe "action_put" do it "should run a PUT request with the message as the payload" do - expect(@http).to receive(:put).with("http://www.opscode.com/", @new_resource.message, {}) - @provider.run_action(:put) - expect(@new_resource).to be_updated + expect(http).to receive(:put).with("http://www.opscode.com/", new_resource.message, {}) + provider.run_action(:put) + expect(new_resource).to be_updated end it "should inflate a message block at runtime" do - @new_resource.message(lambda { "return" }) - expect(@http).to receive(:put).with("http://www.opscode.com/", "return", {}) - @provider.run_action(:put) - expect(@new_resource).to be_updated + new_resource.message(lambda { "return" }) + expect(http).to receive(:put).with("http://www.opscode.com/", "return", {}) + provider.run_action(:put) + expect(new_resource).to be_updated end end describe "action_post" do it "should run a PUT request with the message as the payload" do - expect(@http).to receive(:post).with("http://www.opscode.com/", @new_resource.message, {}) - @provider.run_action(:post) - expect(@new_resource).to be_updated + expect(http).to receive(:post).with("http://www.opscode.com/", new_resource.message, {}) + provider.run_action(:post) + expect(new_resource).to be_updated end it "should inflate a message block at runtime" do - @new_resource.message { "return" } - expect(@http).to receive(:post).with("http://www.opscode.com/", "return", {}) - @provider.run_action(:post) - expect(@new_resource).to be_updated + new_resource.message { "return" } + expect(http).to receive(:post).with("http://www.opscode.com/", "return", {}) + provider.run_action(:post) + expect(new_resource).to be_updated end end describe "action_delete" do it "should run a DELETE request" do - expect(@http).to receive(:delete).with("http://www.opscode.com/", {}) - @provider.run_action(:delete) - expect(@new_resource).to be_updated + expect(http).to receive(:delete).with("http://www.opscode.com/", {}) + provider.run_action(:delete) + expect(new_resource).to be_updated end end @@ -107,52 +95,52 @@ describe Chef::Provider::HttpRequest do # and false for a "304 Not Modified" response describe "action_head" do before do - @provider.http = @http + provider.http = http end it "should inflate a message block at runtime" do - @new_resource.message { "return" } - expect(@http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil) - @provider.run_action(:head) - expect(@new_resource).to be_updated + new_resource.message { "return" } + expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil) + provider.run_action(:head) + expect(new_resource).to be_updated end it "should run a HEAD request" do - expect(@http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil) - @provider.run_action(:head) - expect(@new_resource).to be_updated + expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil) + provider.run_action(:head) + expect(new_resource).to be_updated end it "should update a HEAD request with empty string response body (CHEF-4762)" do - expect(@http).to receive(:head).with("http://www.opscode.com/", {}).and_return("") - @provider.run_action(:head) - expect(@new_resource).to be_updated + expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return("") + provider.run_action(:head) + expect(new_resource).to be_updated end it "should update a HEAD request with nil response body (CHEF-4762)" do - expect(@http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil) - @provider.run_action(:head) - expect(@new_resource).to be_updated + expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil) + provider.run_action(:head) + expect(new_resource).to be_updated end it "should not update a HEAD request if a not modified response (CHEF-4762)" do if_modified_since = File.mtime(__FILE__).httpdate - @new_resource.headers "If-Modified-Since" => if_modified_since - expect(@http).to receive(:head).with("http://www.opscode.com/", { "If-Modified-Since" => if_modified_since }).and_return(false) - @provider.run_action(:head) - expect(@new_resource).not_to be_updated + new_resource.headers "If-Modified-Since" => if_modified_since + expect(http).to receive(:head).with("http://www.opscode.com/", { "If-Modified-Since" => if_modified_since }).and_return(false) + provider.run_action(:head) + expect(new_resource).not_to be_updated end it "should run a HEAD request with If-Modified-Since header" do - @new_resource.headers "If-Modified-Since" => File.mtime(__FILE__).httpdate - expect(@http).to receive(:head).with("http://www.opscode.com/", @new_resource.headers) - @provider.run_action(:head) + new_resource.headers "If-Modified-Since" => File.mtime(__FILE__).httpdate + expect(http).to receive(:head).with("http://www.opscode.com/", new_resource.headers) + provider.run_action(:head) end it "doesn't call converge_by if HEAD does not return modified" do - expect(@http).to receive(:head).and_return(false) - expect(@provider).not_to receive(:converge_by) - @provider.run_action(:head) + expect(http).to receive(:head).and_return(false) + expect(provider).not_to receive(:converge_by) + provider.run_action(:head) end end end diff --git a/tasks/rspec.rb b/tasks/rspec.rb index 18f3318e55..f6038d6b9a 100644 --- a/tasks/rspec.rb +++ b/tasks/rspec.rb @@ -77,7 +77,7 @@ begin RSpec::Core::RakeTask.new(sub) do |t| puts "--- Running chef #{sub} specs" t.verbose = false - t.rspec_opts = %w{--profile} + t.rspec_opts = %w{--profile --format doc} t.pattern = FileList["spec/#{sub}/**/*_spec.rb"] end end |