Port test_warn_bundled_gems.rb to RSpec example

This commit is contained in:
Hiroshi SHIBATA 2024-11-14 17:27:42 +09:00
Родитель 31bdffb5b9
Коммит b44272fcb4
4 изменённых файлов: 30 добавлений и 18 удалений

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

@ -52,7 +52,11 @@ module Gem::BUNDLED_GEMS
WARNED = {} # unfrozen WARNED = {} # unfrozen
conf = ::RbConfig::CONFIG conf = ::RbConfig::CONFIG
LIBDIR = (conf["rubylibdir"] + "/").freeze if !File.exist?(conf["rubylibdir"])
LIBDIR = (File.expand_path(File.join(__dir__, "..", "lib")) + "/").freeze
else
LIBDIR = (conf["rubylibdir"] + "/").freeze
end
ARCHDIR = (conf["rubyarchdir"] + "/").freeze ARCHDIR = (conf["rubyarchdir"] + "/").freeze
dlext = [conf["DLEXT"], "so"].uniq dlext = [conf["DLEXT"], "so"].uniq
DLEXT = /\.#{Regexp.union(dlext)}\z/ DLEXT = /\.#{Regexp.union(dlext)}\z/

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

@ -0,0 +1,25 @@
require "bundled_gems"
RSpec.describe "bundled_gems.rb" do
def script(code, options = {})
options[:artifice] ||= "compact_index"
ruby("require 'bundler/inline'\n\n" + code, options)
end
it "Show warning require and LoadError" do
script <<-RUBY
gemfile do
source "https://rubygems.org"
end
begin
require "csv"
rescue LoadError
end
require "ostruct"
RUBY
expect(err).to include(/csv was loaded from (.*) from Ruby 3.4.0/)
expect(err).to include(/ostruct was loaded from (.*) from Ruby 3.5.0/)
end
end

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

@ -1,9 +1,5 @@
#!/bin/bash #!/bin/bash
echo "* Show warning require and LoadError"
ruby test_warn_bundled_gems.rb
echo
echo "* Show warning when bundled gems called as dependency" echo "* Show warning when bundled gems called as dependency"
ruby test_warn_dependency.rb ruby test_warn_dependency.rb
echo echo

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

@ -1,13 +0,0 @@
require "bundler"
Bundler::Definition.no_lock = true
require "bundler/inline"
gemfile do
source "https://rubygems.org"
end
Object.send(:remove_const, :Bundler)
require "mutex_m"
require "rss"