Use LOAD_PATH instead of require_relative

Seeing that all the contracts library's internal requires are not relative
and then freak out
This commit is contained in:
Rick Bradley 2022-08-09 12:56:02 -05:00
Родитель 11d0b96197
Коммит fd51b0f3d1
3 изменённых файлов: 8 добавлений и 6 удалений

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

@ -5,9 +5,9 @@ require "bundler/setup"
# Note that contracts.ruby has two specific ruby-version specific libraries, which we have vendored into lib/
if (Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0")) # ruby3
require_relative "../lib/contracts-ruby3/lib/contracts"
$LOAD_PATH.unshift(File.expand_path("../lib/contracts-ruby3/lib"))
else # ruby2
require_relative "../lib/contracts-ruby2/lib/contracts"
$LOAD_PATH.unshift(File.expand_path("../lib/contracts-ruby2/lib"))
end
# We don't need Contract outside of normal development

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

@ -23,11 +23,12 @@ require "concurrent"
# Note that contracts.ruby has two specific ruby-version specific libraries, which we have vendored into lib/
if Entitlements.ruby_version2?
require_relative "contracts-ruby2/lib/contracts"
$LOAD_PATH.unshift(File.expand_path("../lib/contracts-ruby2/lib"))
else
require_relative "contracts-ruby3/lib/contracts"
$LOAD_PATH.unshift(File.expand_path("../lib/contracts-ruby3/lib"))
end
require "contracts"
require "erb"
require "logger"
require "ostruct"

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

@ -4,11 +4,12 @@ require "base64"
# Note that contracts.ruby has two specific ruby-version specific libraries, which we have vendored into lib/
if (Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0")) # ruby3
require_relative "../../lib/contracts-ruby3/lib/contracts"
$LOAD_PATH.unshift(File.expand_path("../lib/contracts-ruby3/lib"))
else # ruby2
require_relative "../../lib/contracts-ruby2/lib/contracts"
$LOAD_PATH.unshift(File.expand_path("../lib/contracts-ruby2/lib"))
end
require "contracts"
require "json"
require "rspec"
require "rspec/support"