diff options
author | Tim Smith <tsmith@chef.io> | 2020-07-14 10:24:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-14 10:24:38 -0700 |
commit | 36a92ce258247b44fea1150e2f05f6452a3c0577 (patch) | |
tree | 3c878eefd93e9312767eef61449229ca9cb696f4 /spec/unit | |
parent | ea408a35900900db1bd645446a329e377ccdffa0 (diff) | |
parent | 2732bcc5913a354a5f40a8c9df75307b7e9906b8 (diff) | |
download | chef-36a92ce258247b44fea1150e2f05f6452a3c0577.tar.gz |
Merge pull request #10154 from chef/dont-allow-expectations-on-nil
Don't allow setting expectations on nil.
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/chef_fs/file_system/operation_failed_error_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/cookbook/gem_installer_spec.rb | 3 |
2 files changed, 4 insertions, 5 deletions
diff --git a/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb b/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb index b34d102068..101a002003 100644 --- a/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +++ b/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb @@ -25,11 +25,9 @@ describe Chef::ChefFS::FileSystem::OperationFailedError do context "has a cause attribute and HTTP result code is 400" do it "include error cause" do - allow_message_expectations_on_nil response_body = '{"error":["Invalid key test in request body"]}' - allow(@response).to receive(:code).and_return("400") - allow(@response).to receive(:body).and_return(response_body) - exception = Net::HTTPClientException.new("(exception) unauthorized", @response) + response = double(:response, code: "400", body: response_body) + exception = Net::HTTPClientException.new("(exception) unauthorized", response) expect do raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self, exception), error_message end.to raise_error(Chef::ChefFS::FileSystem::OperationFailedError, "#{error_message} cause: #{response_body}") diff --git a/spec/unit/cookbook/gem_installer_spec.rb b/spec/unit/cookbook/gem_installer_spec.rb index 2733dfc862..58843ac826 100644 --- a/spec/unit/cookbook/gem_installer_spec.rb +++ b/spec/unit/cookbook/gem_installer_spec.rb @@ -95,7 +95,8 @@ describe Chef::Cookbook::GemInstaller do it "skip metadata installation when Chef::Config[:skip_gem_metadata_installation] is set to true" do Chef::Config[:skip_gem_metadata_installation] = true - expect(gem_installer.install).to_not receive(:shell_out!) + expect(gem_installer).to_not receive(:shell_out!) + expect(gem_installer.install).to be_nil end it "install metadata when Chef::Config[:skip_gem_metadata_installation] is not true" do |