Skip to content

Commit

Permalink
DidYouMean can be an empty stub module [Bug #16263]
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Oct 21, 2019
1 parent 1d29c9b commit 2726100
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/ruby/test_exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ def test_nomethod_error_new_receiver
error = NoMethodError.new("Message", :foo)
assert_raise(ArgumentError) {error.receiver}

msg = Object.const_defined?(:DidYouMean) ?
msg = defined?(:DidYouMean.formatter) ?
"Message\nDid you mean? for" : "Message"

error = NoMethodError.new("Message", :foo, receiver: receiver)
Expand Down

3 comments on commit 2726100

@MSP-Greg
Copy link
Contributor

@MSP-Greg MSP-Greg commented on 2726100 Oct 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nobu

Just checking about pulling patches from ruby-loco, and this one is failing. Added some debugging, and it shows:

Object.const_defined?(:DidYouMean)       #=> true
defined?(:DidYouMean.formatter).nil?     #=> NilClass

@yuki24
Copy link
Member

@yuki24 yuki24 commented on 2726100 Oct 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably not have the :.

-defined?(:DidYouMean.formatter).nil? # => false
+defined?(DidYouMean.formatter).nil?  # => true

@MSP-Greg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const_defined? takes a symbol, but defined? does not. Everyone knew that, it was the weekend, etc etc. Thanks.

My only question is if DidYouMean is an empty stub, should it fail anyway? Or, if another test is creating a stub and not cleaning it up, this test should fail?

Please sign in to comment.