Added version guard for OpenSSL::Config

This commit is contained in:
Nobuyoshi Nakada 2020-03-10 21:47:18 +09:00
Родитель e4a26cd4f8
Коммит 2fd779fcd9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4BC7D6DF58D8DF60
2 изменённых файлов: 31 добавлений и 12 удалений

Просмотреть файл

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

Просмотреть файл

@ -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