-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test for the help command #418
Conversation
|
||
::Kernel.define_method(:require) do |name| | ||
raise LoadError, "cannot load such file -- rdoc (test)" if name == "rdoc" | ||
original_require(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a typo, but in these tests it's never reached 🙈
test/lib/helper.rb
Outdated
::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\/.*/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expanded it to match rdoc
or rdoc/*
.
@junaruga I think different |
OK. Thanks for the work! |
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
38c4602
to
a87ea90
Compare
a87ea90
to
cc6e6d2
Compare
"help 'String#gsub'\n", | ||
"\n", | ||
]) | ||
IRB.conf[:PROMPT_MODE] = :SIMPLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterzhu2118 This one is needed to reduce noise from the output.
ec9440e
to
df4536e
Compare
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.
df4536e
to
e08c981
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you!
This PR adds tests for 2 of 3 possible
help
command outcomes:rdoc
: it returns the command constant directlyhelp String#gsub
: it renders the argument's document viardoc
Because the
help
command redefines itself based on if rdoc is required succesfully, there's no easy way to recover it to the pre-test state. I think the best way is to reload the command file, but any alternative is welcome.