diff options
author | Tim Smith <tsmith@chef.io> | 2020-07-15 15:13:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-15 15:13:33 -0700 |
commit | 35bbf1262cf5cb0319be980b055a7f8faf335700 (patch) | |
tree | aeb9f1a8fd038b81b35d44d5e96c03887e059937 /spec/functional/resource | |
parent | 58f3e9405c872df1f22886ed6ce4843c7f3d4c2d (diff) | |
parent | 35dba09fdbb12b479b366d0e6a5252566fa47af8 (diff) | |
download | chef-35bbf1262cf5cb0319be980b055a7f8faf335700.tar.gz |
Merge pull request #10153 from chef/raise-on-raise_error
Don't allow tests to set an expectation without specific error type
Diffstat (limited to 'spec/functional/resource')
-rw-r--r-- | spec/functional/resource/group_spec.rb | 8 | ||||
-rw-r--r-- | spec/functional/resource/remote_file_spec.rb | 8 |
2 files changed, 7 insertions, 9 deletions
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 |