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

Make deprecator messaging clearer #125

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/deprecation_toolkit/behaviors/raise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def initialize(current_deprecations, recorded_deprecations)
You have introduced new deprecations in the codebase. Fix or record them in order to discard this error.
#{record_message}

******* The following deprecations were added: *******
#{introduced_deprecations.join("\n")}
******************************************************
EOM

super(message)
Expand All @@ -57,7 +59,9 @@ def initialize(current_deprecations, recorded_deprecations)
The recorded deprecations needs to be updated to reflect your changes.
#{record_message}

****** The following deprecations were removed: ******
#{removed_deprecations.join("\n")}
******************************************************
EOM

super(message)
Expand Down
6 changes: 5 additions & 1 deletion test/deprecation_toolkit/behaviors/raise_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,25 @@ class RaiseTest < ActiveSupport::TestCase
The recorded deprecations needs to be updated to reflect your changes.
You can re-record deprecations by adding the `--record-deprecations` flag when running your tests.

****** The following deprecations were removed: ******
DEPRECATION WARNING: Bar
******************************************************
EOM

deprecator.warn("Foo")
end

test ".trigger raises a DeprecationRemoved when less deprecations than expected are triggerd and mismatches" do
test ".trigger raises a DeprecationRemoved when less deprecations than expected are triggered and mismatches" do
@expected_exception_class = DeprecationRemoved
@expected_exception_message = <<~EOM
You have removed deprecations from the codebase. Thanks for being an awesome person.
The recorded deprecations needs to be updated to reflect your changes.
You can re-record deprecations by adding the `--record-deprecations` flag when running your tests.

****** The following deprecations were removed: ******
DEPRECATION WARNING: A
DEPRECATION WARNING: B
******************************************************
EOM

deprecator.warn("C")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test_.trigger_raises_a_DeprecationRemoved_error_when_deprecations_are_removed:
test_.trigger_does_not_raise_when_deprecations_are_triggered_but_were_already_recorded:
- 'DEPRECATION WARNING: Foo'
- 'DEPRECATION WARNING: Bar'
test_.trigger_raises_a_DeprecationRemoved_when_less_deprecations_than_expected_are_triggerd_and_mismatches:
test_.trigger_raises_a_DeprecationRemoved_when_less_deprecations_than_expected_are_triggered_and_mismatches:
- 'DEPRECATION WARNING: A'
- 'DEPRECATION WARNING: B'
test_.trigger_raises_a_DeprecationMismatch_when_same_number_of_deprecations_are_triggered_with_mismatches:
Expand Down
Loading