summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDavid Rodríguez <[email protected]>2025-03-06 19:45:56 +0100
committerHiroshi SHIBATA <[email protected]>2025-03-10 12:43:36 +0900
commit1a985d36a753e2e867c2a2c37548f514748d8c8e (patch)
treeb5c0fba92e8de9212f111ec5ea1e2605d2421e5e /spec
parent0ca5240d58e292d0b94a0476dbeee07f61bc08c9 (diff)
[rubygems/rubygems] Adapt specs to extraction of irb from ruby-core
This gets our daily Bundler CI back to green. https://github.com/rubygems/rubygems/commit/1bb70f75d2
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12890
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/commands/console_spec.rb20
-rw-r--r--spec/bundler/commands/newgem_spec.rb7
-rw-r--r--spec/bundler/commands/platform_spec.rb7
-rw-r--r--spec/bundler/support/builders.rb35
4 files changed, 61 insertions, 8 deletions
diff --git a/spec/bundler/commands/console_spec.rb b/spec/bundler/commands/console_spec.rb
index dd7461ced4..dbfbec874f 100644
--- a/spec/bundler/commands/console_spec.rb
+++ b/spec/bundler/commands/console_spec.rb
@@ -35,6 +35,8 @@ RSpec.describe "bundle console", readline: true do
end
RUBY
end
+
+ build_dummy_irb
end
end
@@ -46,7 +48,8 @@ RSpec.describe "bundle console", readline: true do
end
install_gemfile <<-G
- source "https://gem.repo1"
+ source "https://gem.repo2"
+ gem "irb"
path "#{lib_path}" do
gem "loadfuuu", require: true
end
@@ -66,6 +69,7 @@ RSpec.describe "bundle console", readline: true do
before do
install_gemfile <<-G
source "https://gem.repo2"
+ gem "irb"
gem "myrack"
gem "activesupport", :group => :test
gem "myrack_middleware", :group => :development
@@ -81,16 +85,19 @@ RSpec.describe "bundle console", readline: true do
end
it "uses IRB as default console" do
+ skip "Does not work in a ruby-core context if irb is in the default $LOAD_PATH because it enables the real IRB, not our dummy one" if ruby_core? && Gem.ruby_version < Gem::Version.new("3.5.0.a")
+
bundle "console" do |input, _, _|
- input.puts("__FILE__")
+ input.puts("__method__")
input.puts("exit")
end
- expect(out).to include("(irb)")
+ expect(out).to include("__irb__")
end
it "starts another REPL if configured as such" do
install_gemfile <<-G
source "https://gem.repo2"
+ gem "irb"
gem "pry"
G
bundle "config set console pry"
@@ -103,14 +110,16 @@ RSpec.describe "bundle console", readline: true do
end
it "falls back to IRB if the other REPL isn't available" do
+ skip "Does not work in a ruby-core context if irb is in the default $LOAD_PATH because it enables the real IRB, not our dummy one" if ruby_core? && Gem.ruby_version < Gem::Version.new("3.5.0.a")
+
bundle "config set console pry"
# make sure pry isn't there
bundle "console" do |input, _, _|
- input.puts("__FILE__")
+ input.puts("__method__")
input.puts("exit")
end
- expect(out).to include("(irb)")
+ expect(out).to include("__irb__")
end
it "does not try IRB twice if no console is configured and IRB is not available" do
@@ -161,6 +170,7 @@ RSpec.describe "bundle console", readline: true do
it "performs an automatic bundle install" do
gemfile <<-G
source "https://gem.repo2"
+ gem "irb"
gem "myrack"
gem "activesupport", :group => :test
gem "myrack_middleware", :group => :development
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index 2389eda521..a7fe31143d 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -478,9 +478,12 @@ RSpec.describe "bundle gem" do
prepare_gemspec(bundled_app("newgem", "newgem.gemspec"))
- gems = ["rake-#{rake_version}"]
+ build_repo2 do
+ build_dummy_irb "9.9.9"
+ end
+ gems = ["rake-#{rake_version}", "irb-9.9.9"]
path = Bundler.feature_flag.default_install_uses_path? ? local_gem_path(base: bundled_app("newgem")) : system_gem_path
- system_gems gems, path: path
+ system_gems gems, path: path, gem_repo: gem_repo2
bundle "exec rake build", dir: bundled_app("newgem")
expect(last_command.stdboth).not_to include("ERROR")
diff --git a/spec/bundler/commands/platform_spec.rb b/spec/bundler/commands/platform_spec.rb
index d5fb0aa499..17183e7546 100644
--- a/spec/bundler/commands/platform_spec.rb
+++ b/spec/bundler/commands/platform_spec.rb
@@ -941,8 +941,13 @@ G
context "bundle console" do
before do
+ build_repo2 do
+ build_dummy_irb
+ end
+
install_gemfile <<-G
- source "https://gem.repo1"
+ source "https://gem.repo2"
+ gem "irb"
gem "myrack"
gem "activesupport", :group => :test
gem "myrack_middleware", :group => :development
diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb
index ca2b7b7067..9fe802716f 100644
--- a/spec/bundler/support/builders.rb
+++ b/spec/bundler/support/builders.rb
@@ -228,6 +228,41 @@ module Spec
end
end
+ # A minimal fake irb console
+ def build_dummy_irb(version = "9.9.9")
+ build_gem "irb", version do |s|
+ s.write "lib/irb.rb", <<-RUBY
+ class IRB
+ class << self
+ def toplevel_binding
+ unless defined?(@toplevel_binding) && @toplevel_binding
+ TOPLEVEL_BINDING.eval %{
+ def self.__irb__; binding; end
+ IRB.instance_variable_set(:@toplevel_binding, __irb__)
+ class << self; undef __irb__; end
+ }
+ end
+ @toplevel_binding.eval('private')
+ @toplevel_binding
+ end
+
+ def __irb__
+ while line = gets
+ begin
+ puts eval(line, toplevel_binding).inspect.sub(/^"(.*)"$/, '=> \\1')
+ rescue Exception => e
+ puts "\#{e.class}: \#{e.message}"
+ puts e.backtrace.first
+ end
+ end
+ end
+ alias start __irb__
+ end
+ end
+ RUBY
+ end
+ end
+
def build_repo(path, **kwargs, &blk)
return if File.directory?(path)