Shopify / Shopify/deprecation_toolkit
DeprecationToolkit currently can't catch deprecations that are generated before tests are executed
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 538
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
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:
class FooModelTest < ActiveSupport::TestCase
should define_enum_for(:status).with([:pending, :completed, :failed])
end
Here's what gets logged:
************************************************************************
Warning from shoulda-matchers:
The `with` qualifier on `define_enum_for` is deprecated and will be
removed in the next major release. Please use `with_values` instead.
************************************************************************
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 before attach_subscriber has been invoked.
Is it possible to subscribe to deprecations earlier in the life of the test process?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/minitest/deprecation_toolkit_plugin.rb, especially attach_subscriber, and reproduce the FooModelTest example from the issue. Trace when the subscriber is installed relative to test declarations. Done means deprecations emitted before individual tests execute are captured without losing the existing test behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100