Skip to content

Commit

Permalink
[ruby/irb] Fix 2 minor issues in test suite
Browse files Browse the repository at this point in the history
* undefine Kernel#irb_original_require in without_rdoc method
* Don't rescue all LoadErrors/NameErrors in test_rendering.rb, just
the one for require 'yamatanooroti'

ruby/irb@52b79806ea
  • Loading branch information
luke-gru authored and matzbot committed Mar 17, 2023
1 parent a206ee6 commit 418cf34
Show file tree
Hide file tree
Showing 2 changed files with 237 additions and 233 deletions.
9 changes: 6 additions & 3 deletions test/irb/helper.rb
Expand Up @@ -57,11 +57,11 @@ def restore_encodings
end

def without_rdoc(&block)
::Kernel.send(:alias_method, :old_require, :require)
::Kernel.send(:alias_method, :irb_original_require, :require)

::Kernel.define_method(:require) do |name|
raise LoadError, "cannot load such file -- rdoc (test)" if name.match?("rdoc") || name.match?(/^rdoc\/.*/)
::Kernel.send(:old_require, name)
::Kernel.send(:irb_original_require, name)
end

yield
Expand All @@ -70,7 +70,10 @@ def without_rdoc(&block)
require_relative "../lib/envutil"
rescue LoadError # ruby/ruby defines EnvUtil differently
end
EnvUtil.suppress_warning { ::Kernel.send(:alias_method, :require, :old_require) }
EnvUtil.suppress_warning {
::Kernel.send(:alias_method, :require, :irb_original_require)
::Kernel.undef_method :irb_original_require
}
end
end
end

0 comments on commit 418cf34

Please sign in to comment.