Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ruby/irb] Don't insert new methods to Test::Unit::TestCase
Ruby CI runs irb and other Ruby core/stdlib tests in the same process. So adding irb-specific helper to Test::Unit::TestCase could potentially pollute other components' tests and should be avoided.
- Loading branch information
1 parent
2022470
commit cb95d83
Showing
3 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module IRB | ||
module TestHelper | ||
def self.without_rdoc(&block) | ||
::Kernel.send(:alias_method, :old_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) | ||
end | ||
|
||
yield | ||
ensure | ||
EnvUtil.suppress_warning { ::Kernel.send(:alias_method, :require, :old_require) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters