diff options
author | Will Jordan <will@code.org> | 2017-02-17 07:16:58 -0800 |
---|---|---|
committer | Will Jordan <will@code.org> | 2017-02-17 07:16:58 -0800 |
commit | 9c389ff678dee6f4801845a1c82884d31b3499be (patch) | |
tree | 620c9ab1a48da1b311cef493c6ee96e88cdacbcf /spec/bundler | |
parent | 873bac15ae7ddb3032114fb61587314840444ba3 (diff) | |
download | bundler-9c389ff678dee6f4801845a1c82884d31b3499be.tar.gz |
simplify `md5_available?` test using `OpenSSL::Digest:MD5.digest`
Diffstat (limited to 'spec/bundler')
-rw-r--r-- | spec/bundler/fetcher/compact_index_spec.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/spec/bundler/fetcher/compact_index_spec.rb b/spec/bundler/fetcher/compact_index_spec.rb index 7888dbf1bd..b0a23cd5a5 100644 --- a/spec/bundler/fetcher/compact_index_spec.rb +++ b/spec/bundler/fetcher/compact_index_spec.rb @@ -35,9 +35,14 @@ RSpec.describe Bundler::Fetcher::CompactIndex do expect(compact_index).to be_available end - it "does not fork" do - expect(compact_index).to receive(:fork).never - compact_index.available? + context "when OpenSSL is not available" do + before do + allow(compact_index).to receive(:require).with("openssl").and_raise(LoadError) + end + + it "returns true" do + expect(compact_index).to be_available + end end context "when OpenSSL is FIPS-enabled", :ruby => ">= 2.0.0" do @@ -45,6 +50,8 @@ RSpec.describe Bundler::Fetcher::CompactIndex do context "when FIPS-mode is active" do before do + allow(OpenSSL::Digest::MD5).to receive(:digest). + and_raise(OpenSSL::Digest::DigestError) allow(Digest::MD5).to receive(:new) do # OpenSSL writes to STDERR and kills the current process with SIGABRT # when FIPS mode prevents MD5 from being used. @@ -56,20 +63,11 @@ RSpec.describe Bundler::Fetcher::CompactIndex do it "returns false" do expect(compact_index).to_not be_available end - - it "outputs nothing to stderr" do - expect { compact_index.available? }.to_not output.to_stderr_from_any_process - end end it "returns true" do expect(compact_index).to be_available end - - it "does fork" do - expect(compact_index).to receive(:fork).and_call_original - compact_index.available? - end end end |