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
"undefined method on nilClass" rather than "for nilClass" #2404
Comments
|
Actually the exact wording of exception messages is not something that is defined and should be relied on. Of course we can discuss which wording is better, but in general tests should not depend on such exact wording Perhaps it's better to change the test to an exemption that is thrown explicitly with a message that the test itself defines? |
|
@steveklabnik rubinius/kernel/delta/kernel.rb Line 74 in 7058a0c
|
|
RubySpec does not specify the text of exceptions because they are for human consumption and MRI often has poorly worded exceptions. Even if MRI's exception messages were stellar, expecting that exceptions are in eg English eliminates the possibility of localization. The class of the exception is what has code semantics. RubySpec does specify the expected exception class in a multitude of specs. Applications and frameworks like Rails have understandably been written from an MRI-centric perspective, but there are presently Rubinius, JRuby, MagLev, IronRuby, Topaz, Opal as significant Ruby implementations. The sooner we address improper reliance on MRI-specific aspects, the better. |
|
Just for the record, I've found many gems in the past month which have some functionality depending exclusively upon MRI's specific printing of backtraces, with a few offering compatibility with JRuby in clunky and awkward ways. |
|
@razielgn I'm curious, which ones? |
|
@razielgn let's start compiling a list. We can send PRs to fix them. That's an easy thing to ask people to do to help out. |
|
@brixen absolutely, it was on my todo list :) |
|
Yup, would love some advice for how to fix this test The Right Way. |
|
The right way is for exception instances to have more information in the form of attributes rather than just a message. That requires fixing Ruby. In this case, looking just at the text you pasted in the original message of this ticket, it looks like something is rescuing an exception and re-raising an The code could use it's own exception message. In that case, spec'ing the message would be reasonable. Of course, the argument against this is that |
Working on getting the rails tests to pass, and found this:
not the 'on' rather than the expected 'for'.
I did a bit of grep-ping, but couldn't figure out where this error would be defined in the rbx source. Any idea what's causing this issue?
The text was updated successfully, but these errors were encountered: