summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-07-13 16:35:06 -0700
committerPete Higgins <pete@peterhiggins.org>2020-07-14 11:10:31 -0700
commitdab3d44e36ba9dc9907085feb95275f3fd1952eb (patch)
treec3b03e419ce39d4f1b0853e4b922083d43150949
parentebfbce99c8c1a4caaa3fb3df98d3b49625883bf4 (diff)
downloadchef-dab3d44e36ba9dc9907085feb95275f3fd1952eb.tar.gz
Don't allow expectations of raising an error without an error type.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r--lib/chef/chef_fs/parallelizer/parallel_enumerable.rb2
-rw-r--r--spec/functional/resource/group_spec.rb8
-rw-r--r--spec/functional/resource/remote_file_spec.rb8
-rw-r--r--spec/spec_helper.rb1
-rw-r--r--spec/unit/chef_fs/parallelizer_spec.rb2
5 files changed, 10 insertions, 11 deletions
diff --git a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
index 08fbcd4a41..5fafc5c88f 100644
--- a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
+++ b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
@@ -145,7 +145,7 @@ class Chef
def each_with_exceptions_unordered
if @each_running
- raise "each() called on parallel enumerable twice simultaneously! Bad mojo"
+ raise "each() called on parallel enumerable twice simultaneously! Bad mojo"
end
@each_running = true
diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb
index 8fca689e68..7e5b0725c1 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -159,8 +159,10 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
# excluded_members can only be used when append is set. It is ignored otherwise.
let(:excluded_members) { [] }
+ let(:expected_error_class) { windows? ? ArgumentError : Mixlib::ShellOut::ShellCommandFailed }
+
it "should raise an error" do
- expect { group_resource.run_action(tested_action) }.to raise_error
+ expect { group_resource.run_action(tested_action) }.to raise_error(expected_error_class)
end
end
@@ -169,8 +171,10 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
group_resource.append(true)
end
+ let(:expected_error_class) { windows? ? Chef::Exceptions::Win32APIError : Mixlib::ShellOut::ShellCommandFailed }
+
it "should raise an error" do
- expect { group_resource.run_action(tested_action) }.to raise_error
+ expect { group_resource.run_action(tested_action) }.to raise_error(expected_error_class)
end
end
end
diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb
index f4a3d5346d..09e4fdccb4 100644
--- a/spec/functional/resource/remote_file_spec.rb
+++ b/spec/functional/resource/remote_file_spec.rb
@@ -409,13 +409,7 @@ describe Chef::Resource::RemoteFile do
it "should not create the file" do
# This can legitimately raise either Errno::EADDRNOTAVAIL or Errno::ECONNREFUSED
# in different Ruby versions.
- old_value = RSpec::Expectations.configuration.on_potential_false_positives
- RSpec::Expectations.configuration.on_potential_false_positives = :nothing
- begin
- expect { resource.run_action(:create) }.to raise_error
- ensure
- RSpec::Expectations.configuration.on_potential_false_positives = old_value
- end
+ expect { resource.run_action(:create) }.to raise_error(SystemCallError)
expect(File).not_to exist(path)
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index fd74a191f1..18a2ae888b 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -116,6 +116,7 @@ RSpec.configure do |config|
config.include(MockShellout::RSpec)
config.filter_run focus: true
config.filter_run_excluding external: true
+ config.raise_on_warning = true
# Explicitly disable :should syntax
# And set max_formatted_output_length to nil to prevent RSpec from doing truncation.
diff --git a/spec/unit/chef_fs/parallelizer_spec.rb b/spec/unit/chef_fs/parallelizer_spec.rb
index d43e48b7bc..3c675e74fe 100644
--- a/spec/unit/chef_fs/parallelizer_spec.rb
+++ b/spec/unit/chef_fs/parallelizer_spec.rb
@@ -405,7 +405,7 @@ describe Chef::ChefFS::Parallelizer do
expect do
b = enum.enum_for(:each)
b.next
- end.to raise_error
+ end.to raise_error(RuntimeError, "each() called on parallel enumerable twice simultaneously! Bad mojo")
end
end
end