mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
Align the conditions for did_you_mean
Probably due to the testing order, sometimes it looks like that `Gem::UnknownCommandError` happens to be used without registered in `DidYouMean`.
This commit is contained in:
parent
7c5ddb793b
commit
ac24f70fb0
@ -21,13 +21,11 @@ class Gem::UnknownCommandError < Gem::Exception
|
||||
end
|
||||
|
||||
def self.attach_correctable
|
||||
return if defined?(@attached)
|
||||
return if method_defined?(:corrections)
|
||||
|
||||
if defined?(DidYouMean) && DidYouMean.respond_to?(:correct_error)
|
||||
DidYouMean.correct_error(Gem::UnknownCommandError, Gem::UnknownCommandSpellChecker)
|
||||
end
|
||||
|
||||
@attached = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ class TestGemCommandManager < Gem::TestCase
|
||||
|
||||
message = "Unknown command pish".dup
|
||||
|
||||
if defined?(DidYouMean)
|
||||
if e.respond_to?(:corrections)
|
||||
message << "\nDid you mean? \"push\""
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user