Skip to content
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

Wisetara/deprecate args active support test case#assert nothing raised for pr #23789

Conversation

wisetara
Copy link

Using arguments (to specify an exception error) with assert_nothing_raised is not recommended, as discussed with Rafael França on #23773.

A deprecation warning has been added to ActiveSupport::TestCase#assert_nothing_raised(*args), and all tests have been updated to use assert_nothing_raised without arguments.

@wisetara
Copy link
Author

Well, there may be a bit too much warning! I see that now. But I don't believe sorting that out will fix the failure:
TemplateDigestorTest#test_logging_of_missing_template [/home/travis/build/rails/rails/actionview/test/template/digestor_test.rb:109]:
Expected /Couldn't\ find\ template\ for\ digesting:\ messages/something_missing/ to match "".
If someone looks at it, would you #1, agree that perhaps a documented deprecation warning above the method is best rather than an actual warning (or I could code it to only show when arguments are passed in, I suppose), and #2, any thoughts on that failure.

@prathamesh-sonpatki
Copy link
Member

r? @rafaelfranca

@@ -75,6 +75,11 @@ def test_order
# perform_service(param: 'no_exception')
# end
def assert_nothing_raised(*args)
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you have to check presence of arguments. Now it's giving deprecation error every time even if you don't send any parameter to it.

@wisetara wisetara force-pushed the wisetara/deprecate-args-ActiveSupport__TestCase#assert_nothing_raised-for-pr branch from 70fadc0 to f888262 Compare Feb 22, 2016
@wisetara
Copy link
Author

That's better! I hope this deprecation PR is helpful, @rafaelfranca! Please let me know if you'd like any additional changes.

@@ -1,3 +1,13 @@
* Deprecate `(*args)` on `assert_nothing_raised`.

Using arguments (to specify an exception error) with
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for mentioning me but we usually don't do that.

What do you think about?

Deprecate arguments on `assert_nothing_raised`.

`assert_nothing_raised` were not asserting the arguments that were being passed
(usually an specific exception class) since it only yields the block. To not confuse the
users that the arguments have any meaning they are being deprecated.

@rafaelfranca
Copy link
Member

Awesome work. I made some comment.

@rafaelfranca rafaelfranca added this to the 5.0.0 milestone Feb 23, 2016
@wisetara wisetara force-pushed the wisetara/deprecate-args-ActiveSupport__TestCase#assert_nothing_raised-for-pr branch from f888262 to d96550b Compare Feb 23, 2016
@wisetara
Copy link
Author

Thank you for the comments and feedback. I've incorporated your if-else refactor on testcase.rb, and I modified the CHANGELOG.md. I've rebased, and I hope this is good, but if you'd like any other changes, please let me know. It feels good to contribute!

rafaelfranca added a commit that referenced this pull request Feb 23, 2016
…eSupport__TestCase#assert_nothing_raised-for-pr

Wisetara/deprecate args active support  test case#assert nothing raised for pr
@rafaelfranca rafaelfranca merged commit 3adc35a into rails:master Feb 23, 2016
@rafaelfranca
Copy link
Member

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants