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
Use NameError#name to assert raised error. #11993
Use NameError#name to assert raised error. #11993
Conversation
@@ -319,7 +319,7 @@ def test_render_partial_without_object_or_collection_does_not_generate_partial_n | |||
exception = assert_raises ActionView::Template::Error do | |||
@controller_view.render("partial_name_local_variable") | |||
end | |||
assert_match "undefined local variable or method `partial_name_local_variable'", exception.message | |||
assert_equal :partial_name_local_variable, exception.original_exception.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.
I'm happy to merge it, but first let me ask: can this guarantee what the test is supposed to check? It checks that a local variable is not generated, which was clear in the message before.
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.
It checks that a local variable is not generated, which was clear in the message before.
I'm not sure about that, but all NameError subclasses (including NoMethodError) respond to #name
� (since 1.9), so this should be keeping the original intention.
Could you give me more background about this test?
Any news on this? I'd love to see this merged, if it's not 100% OK I can improve it. :) |
This makes the test compatible with other Ruby implementations, which may implement error messages differently.
This seems a little less clear than the change that was similarly merged in 0bc95ed. Happy to help get this finished up or closed out though. ✨ |
Hi Kyle, thanks for looking at this. |
@razielgn seems reasonable. Just adding my two cents to hopefully help @carlosantoniodasilva get this merged or closed. 😀 |
cc @robin850 |
@razielgn : Thanks a lot for your patch! Could you please add an assertion to make sure that the exception is an instance of |
@razielgn : Any chance to update your patch please ? :-) |
…t-error Use NameError#name to assert raised error.
Merging per @robin850 comment ("Asking to assert that this was a NoMethodError was useless as it's an ActionView::Template::Error, sorry for the noise here") |
This makes the test compatible with other Ruby implementations, which may implement error messages differently.