diff options
author | Pete Higgins <pete@peterhiggins.org> | 2020-07-13 17:02:17 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-07-15 12:33:46 -0700 |
commit | 1d292643ed89902f387bead905e600034f58c544 (patch) | |
tree | 7344c21f81302d05a90debdd7b37d6097cff1f98 /spec | |
parent | 3ab9e0aa884f2b792cfedaf945d931e80aba6d48 (diff) | |
download | chef-1d292643ed89902f387bead905e600034f58c544.tar.gz |
Don't allow setting 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 e85a417578..76133c52dc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -124,6 +124,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 5cb995e33b..2f3584f850 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 |