diff options
author | Pete Higgins <pete@peterhiggins.org> | 2020-07-13 17:02:17 -0700 |
---|---|---|
committer | Pete Higgins <pete@peterhiggins.org> | 2020-07-13 17:09:32 -0700 |
commit | 2732bcc5913a354a5f40a8c9df75307b7e9906b8 (patch) | |
tree | b2bbd98de3f4e984242bf343cd18072f04708db9 /spec | |
parent | 7b282172c680d07ddac8e62093b77383206dbf41 (diff) | |
download | chef-2732bcc5913a354a5f40a8c9df75307b7e9906b8.tar.gz |
Don't allow setting expectations on nil.dont-allow-expectations-on-nil
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec_helper.rb | 1 | ||||
-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 |
3 files changed, 5 insertions, 5 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5dba5ea0be..fd74a191f1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -125,6 +125,7 @@ RSpec.configure do |config| end config.mock_with :rspec do |c| c.syntax = :expect + c.allow_message_expectations_on_nil = false end # Only run these tests on platforms that are also chef workstations 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 |