1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Added version guard for OpenSSL::Config

This commit is contained in:
Nobuyoshi Nakada 2020-03-10 21:47:18 +09:00
parent e4a26cd4f8
commit 2fd779fcd9
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 31 additions and 12 deletions

View file

@ -1,20 +1,23 @@
require_relative '../../../spec_helper' require_relative '../../../spec_helper'
require_relative '../shared/constants' require_relative '../shared/constants'
require_relative '../shared/version'
require 'openssl' require 'openssl'
describe "OpenSSL::Config#freeze" do openssl_version_is(""..."2.2") do
it "needs to be reviewed for completeness" describe "OpenSSL::Config#freeze" do
it "needs to be reviewed for completeness"
it "freezes" do it "freezes" do
c = OpenSSL::Config.new c = OpenSSL::Config.new
-> { -> {
c['foo'] = [ ['key', 'value'] ] c['foo'] = [ ['key', 'value'] ]
}.should_not raise_error }.should_not raise_error
c.freeze c.freeze
c.frozen?.should be_true c.frozen?.should be_true
-> { -> {
c['foo'] = [ ['key', 'value'] ] c['foo'] = [ ['key', 'value'] ]
}.should raise_error(TypeError) }.should raise_error(TypeError)
end
end end
end end

View file

@ -0,0 +1,16 @@
require 'openssl'
class OpenSSLVersionGuard < VersionGuard
FULL_OPENSSL_VERSION = SpecVersion.new OpenSSL::VERSION
def match?
if Range === @version
@version.include? FULL_OPENSSL_VERSION
else
FULL_OPENSSL_VERSION >= @version
end
end
end
def openssl_version_is(*args, &block)
OpenSSLVersionGuard.new(*args).run_if(:openssl_version_is, &block)
end