Open rmacklin opened 5 years ago
@Edouard-chin Any thoughts on this issue? Also, would you be able to cut a new release?
👋 I dug a bit on this issue, it's non trivial to fix since Minitest will init the plugin only only during the ruby at_exit
hook https://github.com/seattlerb/minitest/blob/e6bc4485730403faff6966c1671cf5de72b2d233/lib/minitest.rb#L53 (way after the class and any class method call happen).
For now I don't have a solution without monkypatching minitest which I want to avoid. Will keep the issue open for now and find when I have the time if there is a better alternative.
I released v1.0.3 https://rubygems.org/gems/deprecation_toolkit/versions/1.0.3
Thanks for releasing that!
I took a stab at one way we could catch deprecations that are emitted at class-evaluation time: https://github.com/Shopify/deprecation_toolkit/pull/25
It's not perfect - see https://github.com/Shopify/deprecation_toolkit/pull/25#issuecomment-433220570
Consider this example of a deprecation warning: https://github.com/thoughtbot/shoulda-matchers/blob/94b28e4ef4cc001b1c0b4386143b8c05ac163550/lib/shoulda/matchers/warn.rb#L20-L25
A test like this would trigger that deprecation:
Here's what gets logged:
However, because the deprecated method (
with
) is called in the code that declares the test cases, not called from within a test,DeprecationToolkit
won't catch this deprecation. The deprecation gets logged beforeattach_subscriber
has been invoked.Is it possible to subscribe to deprecations earlier in the life of the test process?