зеркало из https://github.com/github/ruby.git
Added version guard for OpenSSL::Config
This commit is contained in:
Родитель
e4a26cd4f8
Коммит
2fd779fcd9
|
@ -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
|
Загрузка…
Ссылка в новой задаче